Change language

Why you should choose the Flask framework for your next project

|

Flask is a framework for building web applications in the Python programming language, using the Werkzeug toolkit as well as the Jinja2 templating engine. It belongs to the category of so-called microframeworks - minimalistic web application frameworks that deliberately provide only the most basic features.

Flask depends on some external libraries - such as Werkzeug and Jinja2.

Werkzeug is a toolkit for WSGI, the standard Python interface between web applications and various servers. It is designed for both development and deployment.

Jinja2 is a templating tool:

Пример работы шаблонизатора Jinja2

An example of a minimal Flask application "Hello World!

Пример Hello World на Flask

An example of a Flask application with the templating engine:

Пример приложения на Flask

Built in features

  • Development Server and Debugger
  • Integrated unit testing support
  • Sending RESTful requests
  • Use of Jinja2 Template Engine
  • Support for secure cookies (client-side sessions)
  • 100% WSGI 1.0 compliant
  • Unicode
  • Extensive documentation
  • Google App Engine compatibility
  • Extensions to enhance desired features

Applications for Flask

A series of extension packages for Flask are supported by the community. Their name usually starts with flask-, e.g. flask-login, flask-sqlalchemy, flask-wtf.

Flask is a constructor, so all extra features will have to be installed manually. The framework is very well suited for small projects, working mostly with static content. Also suitable for creating microservices. The lack of a built-in ORM allows you to choose the right one for your needs. De facto use SqlAlchemy.

Flask 2.0

As of May 2021, Flask started updating and introducing asynchronous mode of operation. You can see the syntax below:

from flask import Flask
app = Flask(__name__)
@app.get('/')
async def ping():
    return {'message': 'pong'}

if __name__ == '__main__':
    app.run(host='0.0.0.0')

When to use Flask

  • If you need a simple backend.
  • If you want to do your own pet project.
  • If you are not familiar with asynchrony.
  • If you want to get more experience and learning opportunities.
  • If you need more control over the components you use.

Flask documentation

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically