---
# System prepended metadata

title: 在Flask下實做WebSocket，非Socket.io（待更新）
tags: [Socket.io, Python, WebSocket, Flask]

---

# 當直接使用
```py
sockets=Sockets(app)
@sockets.route('/hello',websocket=True)
def onHello(ws):
	pp('onHello')
	while not ws.closed:
		msg=ws.receive()
		print(msg)
		data = datetime.datetime.now()
		ws.send(str(data))
```
會產生**WebsocketMismatch**錯誤，所以需要修改


|連結標題|連結網址|功能說明|
|-|-|-|
|Python基于Flask框架实现Websocket通信（待更新）|https://blog.csdn.net/qq_47452807/article/details/124460225 |簡體中文說明如何實做，但會碰到Flask/flask_sockets/Werkzeug版本等等錯誤。|
|Set websocket=True for Rule|https://github.com/heroku-python/flask-sockets/pull/82/commits/b33c5798151ad8efdf1553d5925c699940231b37|需要修改flask_sockets原始碼（pip install 下來的東西）|
