需要在Flask中实现Websocket,以便于实现服务器和客户端的实时数据沟通。
搜:
flask websocket
参考:
-》
总体感觉:
还是miguelgrinberg的Flask-SocketIO更好用。
不过,也还是先去简单对比一下:
然后想办法去试试:Flask-SocketIO
但是结果出错了:
【已解决】websocket启动出错:gunicorn.errors.HaltServer HaltServer App failed to load 4
再去想办法搞清楚,是不是:
Flask-Restful中,如何支持:Flask-Restful
搜:
Flask-Restful Flask-SocketIO
python – Flask: A RESTful API and SocketIO Server – Stack Overflow
python – To implement a web socket feature with Flask-Restful (REST Api) on the server side – Stack Overflow
Flask-SocketIO, Background Threads , Jquery, Python Demo – Timmy Reilly’s Blog
希望用flask作为中介让python和js交互,大家有什么比较好的实践经验没? – 知乎
Miguel Grinberg (miguelgrinberg) on GitHub – Libraries.io
Flask-SocketIO Notifications |var namespace = ‘/notifs’;
var socket = io.connect(location.protocol + "//" + location.host + namespace, {reconnection: false});
【未解决】Simple WebSocket Client测试Flask的websocket显示OPENING且弹出undefined对话框
然后还是没解决。
继续去尝试:
【未解决】Flask-SocketIO测试出错:WebSocket connection to failed Error during WebSocket handshake Unexpected response code 400
要不抽空去试试:
Simple Websocket echo client/server with Flask and gevent / gevent-websocket · GitHub
GitHub – kennethreitz/flask-sockets: Elegant WebSockets for your Flask apps.
Flask 如何实现websocket
python使用websocket的几种方式 | 惊鸟的技术小站
到时候也可以考虑试试这个:
GitHub – zeekay/flask-uwsgi-websocket: High-performance WebSockets for your Flask apps powered by uWSGI.
WebSocket with Flask
然后,对于之前安装了,但是没用到的库,都去删除掉:
pip uninstall Flask-SocketIO
pip uninstall python-socketio
pip uninstall python-engineio
注:
flask-sockets需要依赖gevent
好像gevent是需要依赖greenlet
的。
所以不删。