Easy Flask with NGINX
As one of the more popular Python frameworks, Flask is an extremely lightweight yet powerful system for web applications. Seen as more of a micro framework, a functional Flask application can be as simple as 20 lines of code.

Getting ready
This recipe is based on a very simple, single file Flask application. To show the simplicity, here's the example (demoapp.py
) we'll use:
from flask import Flask application = Flask(__name__) @application.route("/") def hello(): return "<h1>Demo via Nginx with uWSGI!</h1>" if __name__ == "__main__": application.run(host='127.0.0.1', port=9001)
Like the Django recipe, we're going to use uWSGI for the application server in this scenario as well. If you haven't installed uWSGI yet, the best way is to install the latest version via pip
:
apt-get install python-pip python-dev pip install uwsgi
How to do it...
- First up, we set up our
uwsgi.ini
file, which should be located in the root of your Flask application. Here...