【问题记录】WARNING: This is a development server. Do not use it in a production deployment.

问题描述

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

【问题记录】WARNING: This is a development server. Do not use it in a production deployment._第1张图片

示例代码

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

原因分析

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

解决方案

方法一

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

方法二

from wsgiref.simple_server import make_server
 
if __name__ == '__main__':
    server = make_server('', 5000, app)
    server.serve_forever()

【问题记录】WARNING: This is a development server. Do not use it in a production deployment._第2张图片

你可能感兴趣的:(问题记录,python,flask)