from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello():
return 'HELLO WORLD'
[uwsgi]
chdir = /path/to/app.py
module = app
callable = app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
Create file for configuration. sudo vim /etc/init/myproject.conf
description "uWSGI server instance configured to serve myproject"
start on runlevel [2345]
stop on runlevel [!2345]
setuid ubuntu
setgid www-data
env PATH=/path/to/virtualenv/bin
chdir /path/to/app
exec uwsgi --ini wsgi.ini
upstream myproject{
server unix:/path/to/myproject.sock;
}
server {
listen 80;
server_name _;
error_log /var/log/nginx/myproject-error.log;
access_log /var/log/nginx/myproject-access.log combined;
location / { try_files $uri @yourapplication; }
location @yourapplication {
uwsgi_pass myproject;
include uwsgi_params;
}
}