python, uwsgi, nginx
pip install uwsgi
file name:
foobar.py
file content:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
output -> 'Hello World' show on localhost:9090
confog.ini
[uwsgi]
socket=127.0.0.1:3031
wsgi-file=foobar.py
master=true
processes=4
threads=2
stats=127.0.0.1:9191
path of ubuntu:
/etc/nginx/sites-enabled/default
change location:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
server.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '<h1>Hello World</h1>'
if __name__ == '__main__':
app.run(debug=True)
after update:
[uwsgi]
socket=127.0.0.1:3031
wsgi-file=server.py
master=true
processes=4
threads=2
stats=127.0.0.1:9191
callable=app
output -> 'Hello World' show on localhost page
Install Nginx In Ubuntu
uWSGI Offical Document
Nginx + uWSGI 中文