Someone can probably help you, but I'm not sure if they will have the willingness to do that... Please follow our template: https://github.com/tiangolo/fastapi/blob/master/.github/ISSUE_TEMPLATE/question.md
It really helps us to help you :tada:
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
import uvicorn
app = FastAPI()
@app.websocket(path='/ws')
async def websocket_endpoint(websocket: WebSocket):
try:
await websocket.accept()
print(websocket.client_state)
while True:
data = await websocket.receive_text()
print(data)
await websocket.send_json({'msg':data})
except WebSocketDisconnect:
print(websocket.client_state)
uvicorn.run(app)
This is my code. I just wanna know how to send datas to client outside it. At now I am connecting only one client...
https://github.com/lsm1103/fastapi_websocket.git
You can take a look at this little demo of mine
鍙互鐪嬬湅鎴戠殑杩欎釜灏廳emo
Thanks for the help here everyone! :clap: :bow:
@jorgebg2016 if you are still having problems, please create a new issue following the template step by step. That will guide you to write the question in a way that is easier to help you or even better, will guide you to find the answer yourself. Given that, I'm gonna close this issue.
Most helpful comment
Someone can probably help you, but I'm not sure if they will have the willingness to do that... Please follow our template: https://github.com/tiangolo/fastapi/blob/master/.github/ISSUE_TEMPLATE/question.md
It really helps us to help you :tada: