What is Flask web framework ?
Flask is a lightweight WSGI web application framework. It is developed by Armin Ronacher, who leads an international group of Python enthusiasts named Pocco. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.
In this blog, we are going to discuss –
- Web Framework
- Jinja2 template engine
- Environment Prerequisite
- Install virtual environment
- Flask installation
What is Web Framework?
Web Application Framework or simply web Framework represents a collection of libraries and modules that enables a web developer to write applications without having bother about low-level details such as protocols, thread management etc.
What is WSGI?
WSGI stands for Web Server Gateway Interface, has been adopted as a standard for Python web application development. WSGI is a specification for a universal interface between the web server and the web applications.
What is Werkzeug?
Is a WSGI toolkit, which implements requests, response objects, and other utility functions. This enables building framework on top of it. The Flask framework uses Werkzeug as one of its bases.
What is Jinja2?
Jinja2 is a popular templating engine for Python. A web templating system combines a template with a certain data source to render dynamic web pages.
Flask is often referred to as a micro framework. It aims to keep the core of an application simple yet extensible. Flask does not have built-in abstraction layer for database handling, nor does it have form validation support. Instead, Flask supports the extensions to add such functionality to the application.
Python 2.6 or higher is usually required for Installation of Flask. Although Flask and its dependencies work well with Python 3 or onwards, many Flask extensions do not support it properly. Hence, it is recommended that Flask should be installed on Python 2.7.
Installing virtualenv for development environment
virtualenv is a virtual Python environment builder. It helps a user to create multiple python environments side-by-side. Thereby, it can avoid compatibility issues between the different versions of the libraries.
The following command installs virtualenv
pip install virtualenv
This command needs administrator privileges. Add sudu before pip on Linux/Mac OS.
Sudo apt-get pip install virtualenv
Once installed, the new virtual environment is created in a folder
mkdir myproject cd myproject virtualenv myenv
To activate the corresponding environment, on Linux/OS X, use the following –
On Windows, use the following –
We are now ready to install Flask in this environment.
pip install Flask
So we have finally read about the Flask web framework, virtual environment and Flask installation on our system. If you have any doubt just comment below.
Connect with the author on LinkedIn.
If want to know about Web Scraping click here.