We can implement WebSocket in FastAPI like this:
fromfastapiimportFastAPI, WebSocketapp=FastAPI()
@app.websocket("/ws")asyncdefwebsocket_endpoint(websocket: WebSocket):
awaitwebsocket.accept()
whileTrue:
data=awaitwebsocket.receive_text()
awaitwebsocket.send_text(f"Message text was: {data}")So, as the title suggests, is there an official way to handle WebSockets in PyNest API?
I tried import WebSocket from nest.core but there's no definition for it.
We can implement WebSocket in FastAPI like this:
So, as the title suggests, is there an official way to handle WebSockets in PyNest API?
I tried import
WebSocketfromnest.corebut there's no definition for it.