首席引入依赖安装waitrss
pip intsll waitress
然后在flask程序内引入依赖
使用server()函数代替app.run()函数
启动时,直接python xxx.py即可
from waitress import serve from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World,爱看书的小沐!' if __name__ == '__main__': # app.run() # app.run(host="127.0.0.1", port="8080") # app.run(host='localhost', port=8080, threaded=False, processes=1) serve(app, host='0.0.0.0', port=8080)
优点是可以解决flask自带的web服务器的无响应,低并发等问题
标签:__,web,run,python,app,flask,port,waitress From: https://www.cnblogs.com/qboshi/p/17038638.html