Nginx.conf 中
#flask
server {
listen 80;
server_name flask.rainingway.com
charset utf-8;
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:6543;
client_max_body_size 35m;
uwsgi_read_timeout 180;
}
}
UWSGI.ini 文件
[uwsgi]
# uwsgi 启动时所使用的地址与端口
socket = :6543
# python 启动程序文件
wsgi-file = /root/Flask_test/flask_server.py
# 获取uwsgi统计信息的服务地址
stats = 127.0.0.1:9191
# 在python文件中 app = Flask(__name__) 的app,否则500
callable = app
# 保存pid信息,方便停止服务和重启的时候用
pidfile = uwsgi.pid
# 后台运行时记录uwsgi的运行日志
daemonize = uwsgi.log
#更新py文件后重启wsgi
python-autoreload = 1
flask_server.py测试文件
#!/usr/local/bin/python3 python
# -*- coding=utf-8 -*-
from flask import Flask, url_for, request, render_template
import sys
sys.path
__author__ = 'Ledemon'
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host='0.0.0.0',debug = True)