关于报错:This is a development server. Do not use it in a production deployment.Use a production

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

if __name__ =='__main__':
    app.run(host='0.0.0.0',port=5000)

后来觉得这句Use a production WSGI server instead是关键。所以有以下两种解决方法,首推法1.

关于python中WSGI服务器的两种实现
1.用gevent包里的pywsgi
优点:速度快,第三方开发维护

if __name__ == '__main__':

    from gevent import pywsgi

    server = pywsgi.WSGIServer(('0.0.0.0',5000),app)
    server.serve_forever()

2、用python内置的WSGI服务器
速度反应慢,而且在我的实验环境下能启动运行,但是发送GET和POST请求是返回404和500。无法使用。

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

你可能感兴趣的:(区块链编程的坑,python)