Flask extension
Flask is often referred to as a micro-framework because the core functions include Werkzeug- based WSGI and routing, and Jinja2- based template engine. In addition, the Flask framework also supports cookies and sessions, as well as JSON , static files and other web helpers. Obviously, this is not enough to develop a complete web application. The Flask extension has such a function . Flask extensions provide extensibility for the Flask framework.
There are a large number of Flask extensions available. A Flask extension is a Python module that adds specific types of support to Flask applications. The Flask Extension Registry (Flask Extension Registry) is a directory of available extensions. The required extension can be downloaded through the pip utility.
In this tutorial, we will discuss the following important Flask extensions:
-
Flask Mail -Provides an SMTP interface for Flask applications
-
Flask WTF -Add rendering and validation of WTForms
-
Flask SQLAlchemy -Add SQLAlchemy support to Flask applications
-
Flask Sijax -Sijax interface-Python/jQuery library, making AJAX easy to use in web applications
Each type of extension usually provides extensive documentation on its usage. Since the extension is a Python module, you need to import it to use it. The Flask extension is usually named flask-foo. The import operation is as follows:
from flask_foo import [class, function]
For Flask versions after 0.7, you can also use the syntax:
from flask.ext import foo
For this usage, the compatibility module needs to be activated. It can be installed by running flaskext_compat.py:
import flaskext_compat
flaskext_compat.activate()
from flask.ext import foo