Flask extension Flask is often referred to as a microframe because core functions include Werkzeg based WSGI and routing and the Jinja2-based template engine.

In addition, the Flask framework supports cookies and sessions, as well as web help programs such as JSON, static files, and so on.

Obviously, this is not enough to develop a complete web application. Flask extensions help you get more functionality.The Flask extensions provide scalability for the Flask framework.

There is a large number of Flask extensions available.

Related course: Python Flask: Create Web Apps with Flask

Extensions

The Flask extension is a Python module that adds specific types of support to the Flask application.

The Flask Extension Registry (Flask Extension Registry) is an available extension directory.The required extension can be downloaded via the pip utility.

In this tutorial, we will discuss the following important Flask extensions:

  • Flask Mail - Provides an SMTP interface for the Flask application

  • Flask WTF - Add rendering and validation of WTForms

  • Flask SQLAlchemy - Adding SQLAlchemy support for the Flask application

  • Flask Sijax-Sijax - interface-Python/jQuery library to make AJAX easy to use in web applications

Each type of extension typically provides a large number of documents about its usage.Because the extension is a Python module, you need to import it to use it.

How to import

The Flask extension is typically named something like flask-foo.

The import is as follows:

1
from flask_foo import [class, function]

For the Flask version after 0.7, you can also use the syntax:

1
from flask.ext import foo

Sometimes the compatibility module needs to be activated.It can be installed by running the flaskext_compat.py:

1
2
3
import flaskext_compat
flaskext_compat.activate()
from flask.ext import foo

Related course: Python Flask: Create Web Apps with Flask