Flask Extensions
What they are and how do you install Flask Extension?
This article covers some important extensions for Flask. They are relatively easy to use. Read on, let’s check them out together.
Why Flask Extension?
It is general knowledge that Flasks are micro-web models owing to the fact that their major operations solely entail Werkzueg based WSGI, routing, and jinja2-based template engine.
It endorses front-end characteristics like static files and JSON. It also endorses sessions and cookies.
The flask Extensions come in handy in this regard. Using the Flask model you can execute so many more tasks with the Flask-Extensions.
Related course: Create Web Apps with Python Flask
Flask extensions
There are quite a number of available Flash Extensions. The frequently used Flask-Extension will be discussed here.
Few crucial Flask Extensions
Extensions | Usefulness |
---|---|
Flask-sijax | Sijax is a library of python/jQuery that makes using AJAX on web applications relatively easy. Flask-sijax adds sijax to the flask applications. |
Flask-login | For flash web applications, it offers user validation functionality |
Flask SQLAlchemy | This particular extension is quite unique in that it offers an exemplar kind of interface, to conveniently interact with the tables on a database. |
Flask-mail | These Extensions offer an SMTP interface for flask applications to interact via emails, you can send and receive emails to users/clients. |
Flask-WTF | The Flask-WTF is a special extension that offers an |
Flask-Debugtoolbar | This extension is unique in its own right. It offers a potent toolbar for debugging which is basically designed to debug flask applications. |
Install Flask Extensions
All of these extensions are modules of Python which broadens the practicalities of Flask application. Therefore, you can easily install them in a similar vein to the python library using the pip utility.
The structure you will use to install a Flask-Extension flask-foo is:
pip install flask-foo
#pip install flask-Sqlalchemy
#pip install flask-wtf
#pip install flask-mail
#pip install flask-login
#pip install flask-debugtoolbar
#pip install flask-sijax
Importing is also similar and easy just like it is with importing a python library
from flask_foo import ...
Using a higher version of a flask, any version higher than the 0.7, you can import using flash. ext. The structure is:
from flask.ext import foo #sqlalchemy, login .....
If your compatibility module is not on, you tend to get errors. To activate the compatibility module, you can use this code:
import flaskext_compat
flaskext_compat.activate()
from flask.ext import foo
The moment you activate it, just like the former way you can also use a flask. ext.
Conclusion
There you go, this is the last piece of the articles in the flask Tutorial series. Enjoy Coding.
Related course: Create Web Apps with Python Flask