uwsgi部署flask
最简单的uwsgi启动flask项目
__WuJian 2019-11-04 21:40:26 262 收藏
分类专栏: Python3
版权
运行环境Ubuntu
目录结构
.
└── test
├── app.py
└── flask_uwsgi.py
app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return "Hello World"
if __name__ == "__main__":
app.run(host="0.0.0.0")
flask_uwsgi.py
from app import app
if __name__ == "__main__":
app.run()
使用uwsgi启动的命令
uwsgi --http 0.0.0.0:8000 --wsgi-file flask_uwsgi.py --callable app --master
1
方法2
构造uwsgi.ini 文件
目录结构
.
└── test
├── app.py
├── flask_uwsgi.py
└── uwsgi.ini
ini文件内容
[uwsgi]
http-socket = :5000
chdir = .
virtualenv = /home/hy/.pyenv/versions/env
wsgi-file = flask_uwsgi.py
callable = app
master = true
启动命令
uwsgi --ini uwsgi.ini