What is Flask?
Flask is a popular Python web framework, a third-party Python library used for developing web applications.
What is the purpose of Web Framework in Python?
When a user develops a Python application, it is called as “command line applications” for which the user has to run these scripts in a shell or command prompt and pass input as arguments. This kind of applications is to build desktop applications — a program that allows users to interact using a mouse and keyboard, which contains menus and other interactive elements. In order build web applications — your users will interact with your program via their web browser. In order to build a web application, a web framework is necessary. Flask is one of the simple and powerful web framework for Python.
How to install Flask?
First you need a virtual environment to install flask. Once you install the virtual environment, use the following command
pip install flask
First you need to install Anaconda Navigator. Anaconda Navigator is a desktop graphical user interface that allows you to launch applications and easily manage conda packages, environments and channels without the need to use command line commands. It will also install latest version of python.
Once installation is completed, open Anaconda Prompt and use the following command
pip install flask
The following is a simple python program with flask. The below code shows “Hello, World!” on “localhost:5000” in a web browser when run with the python app.py command and the Flask library installed.
from flask import Flask
app = Flask(__name__)
return “Hello, World!”
if __name__ == “__main__”:
1. It’s lightweight, simple to learn and extensively scalable.
2. A growing community is providing neat solutions to several problems being faced by developers.
3. It is super easy to deploy Flask in production.
To sum up, Flask is one of the most feature-rich micro frameworks available. Flask comes with all the benefits of fast templates, strong WSGI features, thorough unit testability at the web application and library level, extensive documentation which helps us in building projects where good features and a vast number of extensions are needed.