FastAPI WebSocket

樂享極致發表於2020-10-20

此篇文章參考:https://www.cnblogs.com/CharmCode/p/13552551.html

首先安裝 websockets , 別上來就按照文章一段操作如猛虎,回頭一看二百舞
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
fastAPI 中的WebSocket也是基於websockets執行的

不安裝websockets

  • 前端報錯:failed: Error during WebSocket handshake: Unexpected response code: 400
  • 後端報錯:WARNING: Unsupported upgrade request
pip3 install websockets

相關文章