Creating a python flask app

Creating a Python Flask application

The following is simple tutorial on setting up your first python web application using flask. Flask is a microframework for Python based on Werkzeug, Jinja 2. It is one of the simplest python web frameworks you will find.


  • Python 2/3
  • Pip:
    curl -LO
  • Virtualenvwrapper
    pip install virtualenvwrapper


To setup your individual python virtual environment and install the flask application dependencies, run the following in your terminal session:

mkvirtualenv flaskapp
pip install flask

Create the application

In the same terminal session create a file named with the following contents:

from flask import Flask

app = Flask(__name__)

def hello_world():
    return "Hello World"

if __name__ in '__main__':

Start the app

In the same terminal run:


Open up a browser window at: http://localhost:5000


So we managed to get a basic Python Flask web app up and running in seconds. However this is just a basic setup. The application is not multi threaded at this point. To achieve that you would need spend time looking at WSGI which is beyond this beginner tutorial. Its also worth pointing out that there are no Unit Tests as part of this example and that the application routing is just the vanilla Flask implementation which is self contained within the file. Flask has many more advanced features which you should check out.