uWSGI(Web Server Gateway Interface)とはPythonのアプリとWebサーバのプロトコルのこと。
Django, Flask, BottleはこのWSGIの規約にそっている
uWSGIはアプリケーションサーバの一種
通信は
– UNIXドメインソケット(高速)
– HTTP
$ pip3 install uWSGI
一緒にflaskもインストールします。
$ pip3 install flask
run.py
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/')
def api_sample():
result = {"code": "001", "name": "apple"}
return jsonify(ResultSet=result)
if __name__ == '__main__':
app.run(host="0.0.0.0")
ん、どこにuWSGIが使われているんだ??

続いてuWSGIコマンドを実行する
$ uwsgi –http=0.0.0.0:8080 –wsgi-file=run.py –callable=app

なんだこれ? サーバ機能やな
### 設定ファイルから実行する
uwsgi.ini
[uwsgi] wsgi-file=run.py callable=app http=0.0.0.0:8080
$ uwsgi uwsgi.ini
### iniファイルの設定項目
daemonize = /var/log/uwsgi.log log-reopen = true log-maxsize = 8000000 logfile-chown = on logfile-chmod = 644 current_release = /opt/apps/current/sample_api chdir = %(current_release) wsgi-file = %(current_release)/run.py processes = 4 threads = 2 thunder-lock = true max-requests = 3000 max-requests-delta = 300 master = True
なるほど、簡易webサーバを作ってるみたいやな