Flask was created by Armin Ronacher of Pocoo which is an international group of Python enthusiasts formed in 2004. Flask is a lightweight Python web framework based on Werkzeug and Jinja 2, Flask tackles Routing, HTML template rendering, Sessions etc. If you are building web applications on Linux, then I highly recommend using Flask.
Flask is an extremely functional and powerful framework that is most popular and very much extensible with a great choice of third party libraries.
Flask is called a micro framework because it does not presume or force a developer to use a particular tool or library. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself.
The Gunicorn also known as "Green Unicorn" is a Python Web Server Gateway Interface (WSGI) HTTP server. It is a pre-fork worker model, ported from Ruby's Unicorn project.
The Gunicorn server is broadly compatible with a number of web frameworks, simply implemented, light on server resources and fairly fast.
Flask was designed to be easy to use and extend. Flask is great for all kinds of projects. It's especially good for prototyping. Flask depends on two external libraries: the Jinja2 template engine and the Werkzeug WSGI toolkit.
Despite the lack of a major release, Flask has become extremely popular among Python enthusiasts. Flask provides several very useful features, some of them are listed below.
Flask has a lightweight and modular design, so it easy to transform it to the web framework you need with a few extensions without weighing it down
HTTP request handling functionality and High Flexibility
Support for secure cookies (client side sessions) and Integrated support for unit testing
Built-in development server and fast debugger
Flask documentation are comprehensive, full of examples and well structured. You can even try out some sample application to really get a feel of Flask.
Jinja2 templating and WSGI 1.0 compliant
In this tutorial, we will learn how to set up the Gunicorn application server to launch the application and Nginx to act as a front end reverse proxy.
A server running Ubuntu-14.04.
A static IP Address for your server.
A non-root user account with sudo privilege set up on your server.
Nginx is a free, open-source, high-performance HTTP server and reverse proxy server, also known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
It has reached its popularity due to being light weight, relatively easy to work with and easy to extend with add-ons and plug-ins.
Before starting, update the system by running the following commands:
sudo apt-get updatesudo apt-get upgrade
Then, install Nginx by running the following command:
sudo apt-get install nginx
Next, start Nginx service by running the following command:
sudo /etc/init.d/nginx start
Then, add Nginx service to start at boot time by running the following command:
You can test Nginx configuration by running the following command:
sudo nginx -t
You will see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Now, start Nginx service by running the following command:
sudo /etc/init.d/nginx start
Congrats!.. You should now able to see your application by running the following curl command:
You should see the following output:
This is sample Flask App
In this tutorial, you have learned to create a Flask application within a Python virtual environment, create WSGI entry point, configure the Gunicorn app server to provide this function and created an Nginx server block that passes web client traffic to the application server.
You can also design your own app and serve the flask applications.
Facebook0TwitterReddit0StumbleUpon0HostPresto will be launching a European point of presence in the coming weeks, specifically in Amsterdam. For customers needing their data located within the EU still please contact support to request migration to this location with ticket subject ‘EU Migration’. We will ensure this is actioned well before the Brexit...
Facebook0TwitterReddit0StumbleUpon0Should the UK leave the EU without a deal, or should a deal be agreed that does not include a provision for .eu ownership by UK entities, it’s highly likely that the EU will revoke any .eu domain names unless you can provide an EU address. While this won’t happen...
Facebook0TwitterReddit0StumbleUpon0If you own a .co.uk domain name and you have not registered the equivalent .uk version, you have until the 25th June 2019 to register the domain and secure your brand. After this date any unregistered .uk domain will enter public availability – meaning anyone can register the domain. You...