User Tools

Site Tools


Deploying a Flask web app

This how-to guide will, as an example, show how to deploy a Flask web application, but it will also be helpful (to varying degrees) for other frameworks. It is currently a WORK IN PROGRESS.

Assume the app consists of, among other things, a python file called which contains the global variable app, referring to the Flask object.

Setting up the virtual environment

Once you have your app on the appropriate virtual machine, the first step is to create a virtual environment.

Make sure you are in your project folder and run the command python3 -m venv env.

You can now activate this environment by running source env/bin/activate and deactivate it by running deactivate.

With the environment activated, install any Python modules required for your app.


If uWSGI is not installed on the virtual machine, it will need to be installed. If you do not have permissions to do so you may have to ask someone who does.

Now, pick a port number which is not already in use on the machine. For this tutorial, we will use 8000.

You need a uWSGI ini file; the name is not important so we will call it uwsgi.ini. It should have the following text (being sure to replace the main python file name, the name of the Flask object, and port number, if necessary):

strict = true
processes = 4
master = true
die-on-term = true
module = main:app
virtualenv = env
http-socket =


howto/specific/python_web_app.txt · Last modified: 2023/07/29 11:11 by tcmal