问题描述

1
2
3
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.

示例代码

1
2
if __name__ == '__main__':
app.run(debug=True)

原因分析

1
flask未使用 WSGI 启动,将代码改成使用wsgi启动就行了

解决方案

方法一

1
2
3
4
5
from gevent import pywsgi

if __name__ == '__main__':
server = pywsgi.WSGIServer(('127.0.0.1', 5000), app)
server.serve_forever()

方法二

1
2
3
4
5
from wsgiref.simple_server import make_server

if __name__ == '__main__':
server = make_server('', 5000, app)
server.serve_forever()