折腾:
期间,简单对比了:
GitHub – miguelgrinberg/Flask-SocketIO: Socket.IO integration for Flask applications.
GitHub – kennethreitz/flask-sockets: Elegant WebSockets for your Flask apps.
感觉像是:
Flask-SocketIO更加智能和好用。
所以去试试Flask-SocketIO
参考官网:
GitHub – miguelgrinberg/Flask-SocketIO: Socket.IO integration for Flask applications.
Welcome to Flask-SocketIO’s documentation! — Flask-SocketIO documentation
参考其他文档教程:
使用Flask SocketIO实现WebSocket | 风中飞舞
Easy WebSockets with Flask and Gevent – miguelgrinberg.com
去安装:
(RunningFast) ➜ staging pip install flask-socketio Collecting flask-socketio Downloading Flask-SocketIO-2.7.1.tar.gz Requirement already satisfied (use –upgrade to upgrade): Flask>=0.9 in /root/Envs/RunningFast/lib/python2.7/site-packages (from flask-socketio) Collecting python-socketio>=1.5.0 (from flask-socketio) Downloading python-socketio-1.6.0.tar.gz Collecting python-engineio>=1.0.0 (from flask-socketio) Downloading python-engineio-1.0.3.tar.gz Requirement already satisfied (use –upgrade to upgrade): itsdangerous>=0.21 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.9->flask-socketio) Requirement already satisfied (use –upgrade to upgrade): Jinja2>=2.4 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.9->flask-socketio) Requirement already satisfied (use –upgrade to upgrade): Werkzeug>=0.7 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.9->flask-socketio) Requirement already satisfied (use –upgrade to upgrade): click>=2.0 in /root/Envs/RunningFast/lib/python2.7/site-packages (from Flask>=0.9->flask-socketio) Requirement already satisfied (use –upgrade to upgrade): six>=1.9.0 in /root/Envs/RunningFast/lib/python2.7/site-packages (from python-socketio>=1.5.0->flask-socketio) Requirement already satisfied (use –upgrade to upgrade): MarkupSafe in /root/Envs/RunningFast/lib/python2.7/site-packages (from Jinja2>=2.4->Flask>=0.9->flask-socketio) Building wheels for collected packages: flask-socketio, python-socketio, python-engineio Running setup.py bdist_wheel for flask-socketio … done Stored in directory: /root/.cache/pip/wheels/7c/51/76/a099ff7dcc7fd77fc54ad7594572aafd0dd6443f418fc85eec Running setup.py bdist_wheel for python-socketio … done Stored in directory: /root/.cache/pip/wheels/ec/b0/c4/bf6b6d340fa70de5f111aca53fe5916953a0729b73b1319165 Running setup.py bdist_wheel for python-engineio … done Stored in directory: /root/.cache/pip/wheels/18/60/06/274a2f26a91447b4ab42b014b29de3d12ba94ed3a810e6d3b5 Successfully built flask-socketio python-socketio python-engineio Installing collected packages: python-engineio, python-socketio, flask-socketio Successfully installed flask-socketio-2.7.1 python-engineio-1.0.3 python-socketio-1.6.0 |
安装了:
flask-socketio-2.7.1 python-engineio-1.0.3 python-socketio-1.6.0
加了代码
但是现在不知道如何去测试了:
然后再去想办法测试接口:
【已解决】Flask的Websocket的Flask-SocketIO的接口测试
虽然后续搞清楚如何测试了:
但是最终还是无法解决后续的错误:
【未解决】Flask-SocketIO测试出错:POST socket.io EIO 400 BAD REQUEST
【未解决】把gunicorn从19.6降级为18.0后supervisorctl运行出错:gunicorn: error: No application module specified