Skip to content
Thierry Lam edited this page Feb 10, 2023 · 4 revisions

Deploying a flask app

Flask profject structure:

myapp/
    app.py

Installing nginx

sudo apt-get install nginx

Create nginx configuration /etc/nginx/sites-available/myapp

server {
    location / { try_files $uri @yourapplication; }

    location @yourapplication {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
    }
}

Activate the app, from /etc/nginx/sites-enabled

sudo ln -s /etc/nginx/sites-available/myapp myapp

Start nginx

sudo service nginx start

Installing uwsgi

pip install uwsgi

Running uwsgi from myapp/

/home/gdev/.virtualenvs/myapp/bin/uwsgi --socket 0.0.0.0:8080 --protocol=http -w app:app --logto /tmp/myapp_debug.log &

Access the web page at http://your.ip.number:8080

proxy_pass references

Clone this wiki locally