1 – About Flask Framework
Flask is an open-source Python web development framework. Its main goal is to be light, in order to keep the flexibility of Python programming, associated with a system of templates. It is distributed under the BSD license.
Flask was originally created by Armin Ronacher as an April Fool’s . Ronacher’s wish was to create a web framework contained in a single Python file but able to maintain high demand applications.
In 2018, Flask was voted “Most Popular Web Framework” by the Python Developers Survey. As of January 2020, it had over 49,000 stars on Github, more than any other Python web development framework.
2 – Features
Flask is based on two modules werkzeug and jinja to offer several of the following features:
- Development server and debugger
- Simplifies writing unit tests
- Template engine for HTML rendering
- Supports secure cookies (session)
- Fully compatible with WSGI
- Based on Unicode
- Complete documentation
- Easy deployment on multiple hosts
- Adding functionalities via extensions
3 – Install Flask Framework
Install Flask Flask Framework can be installed easily and quickly by using the pip command: Flask:
pip install Flask
4 – First program Hello World with Flask
The basic program for using Flask is:
from flask import Flask
app = Flask(__name__)
return "Hello world !"
if __name__ == "__main__":
After execution you will see this message:
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Then by typing the the url : http://127.0.0.1:5000/ in your browser you will see the “Hello World !” message: