Flask Deploy app
-
Setup server on Linode
-
ssh to it root@IP
-
Create user adduser gabor
-
ssh-copy-id gabor@IP
-
scp * gabor@IP
-
apt update
-
apt upgrade -y
-
reboot
-
apt install -y uwsgi uwsgi-plugin-python3 nginx python3-virtualenv
-
as gabor
-
virtualenv .venv
-
source .venv/bin/activate
-
pip install pytest flask
from flask import Flask
myapp = Flask(__name__)
@myapp.route("/")
def main():
return 'Main'
import app
def test_app():
web = app.myapp.test_client()
rv = web.get('/')
assert rv.status == '200 OK'
assert rv.data.decode('utf-8') == 'Main'
[uwsgi]
http-socket = :9091
chdir = /home/gabor/demo
plugin = python3
wsgi-file = /home/gabor/demo/app.py
process = 3
callable = myapp
virtualenv = /home/gabor/demo/.venv/
server {
server_name example.com;
access_log /var/log/nginx/example.log main;
error_log /var/log/nginx/example.error.log;
location ~ /.git/ {
deny all;
}
#error_page 404 /404.html;
location '/' {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9091;
}
root /home/gabor/work/example.com/html/;
}