flask 项目程序文件
cat /opt/flask_project/app.py
from flask import Flask
app = Flask(name)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/demo")
def demo():
return "Hello World Demo!"
if name == "main":
app.run(host='0.0.0.0', port=5001)
nginx的配置文件:
#cat /etc/nginx/conf.d/app.conf
server {
listen 80;
server_name 101.132.118.195;
location / {
proxy_pass http://127.0.0.1:3099;
}
}
uwsgi的配置文件
#cat /opt/flask_project/app_uwsgi.ini
[uwsgi]
http=127.0.0.1:3099
wsgi-file=/opt/flask_project/app.py
callable=app
touch-reload=/opt/flask_project/
启动nginx和uwsgi服务
先启动uwsgi服务
uwsgi --ini app_uwsgi.ini &
再启动nginx服务
systemctl start nginx
浏览器访问:http://ip地址
本文转自 xxl714 51CTO博客,原文链接:http://blog.51cto.com/dreamgirl1314/2056362,如需转载请自行联系原作者