mkdir test_flask && cd test_flask python3 -m venv .venv source .venv/bin/activate pip install flask pip install uwsgi
app.py
from flask import Flask import datetime app = Flask(__name__) @app.route('/') def index(): now = datetime.datetime.now().strftime('%H:%M:%S.%f') return f'<h1>top page!({now})</h1>\n' @app.route('/sample') def sample(): now = datetime.datetime.now().strftime('%H:%M:%S.%f') return f'<h1>sample page!({now})</h1>\n'
参考
https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
uwsgi起動
uwsgi --http :3031 --wsgi-file app.py --callable app
確認
curl http://localhost:3031/ top page!(13:35:03.767707)
Nginx を参照
apt-get -y install software-properties-common add-apt-repository -y ppa:deadsnakes/ppa apt-get update apt-get -y install python3.6
Dockerfile
FROM ubuntu apt-get update apt-get -y install software-properties-common add-apt-repository -y ppa:jonathonf/python-3.6 apt-get update apt-get -y install python3.6 apt-get -y install nginx ln -s /usr/bin/python3.6 /usr/bin/python rm -rf /usr/bin/python3 ln -s /usr/bin/python3.6 /usr/bin/python3