Flask-SocketIO 的新版本(5.0) 的 文档 中提到:
The
flask run
command introduced in Flask 0.11 can be used to start a Flask-SocketIO development server based on Werkzeug, but this method of starting the Flask-SocketIO server is not recommended due to lack of WebSocket support. Previous versions of this package included a customized version of theflask run
command that allowed the use of WebSocket on eventlet and gevent production servers, but this functionality has been discontinued in favor of thesocketio.run(app)
startup method shown above which is more robust.
这个说明看起来好像是针对采用直接运行python app.py
的方式运行的,问一下 socketio.run(app)
如何改写成可以运行 类似于 Catchat 这样程序包形式的程序呢?
注:这个问题是由于安装了Flask-SocketIO 5.0 后运行flask run
时提示:
The WebSocket transport is not available, you must install a WebSocket server that is compatible with your async mode to enable it. See the documentation for details. (further occurrences of this error will be logged with level INFO)