-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI
app = FastAPI()
@app.websocket("/foo")
async def foo(websocket):
print("FOO")
await websocket.accept()
for line in ["line"]:
await websocket.send_text(line) Descriptionpip install fastapi==0.110.0 uvicorn==0.29.0 websockets==12.0
uvicorn main:app --log-level debug python -m websockets ws://127.0.0.1:8000/foo Uvicorn output:
Client output:
Operating SystemmacOS Operating System DetailsNo response FastAPI Version0.110.0 Pydantic Version2.6.4 Python VersionPython 3.12.2 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
Kludex
Mar 24, 2024
Replies: 1 comment 2 replies
-
Missing the type hint on from fastapi import FastAPI, WebSocket
app = FastAPI()
@app.websocket('/foo')
async def foo(websocket: WebSocket):
print('FOO')
await websocket.accept()
for line in ['line']:
await websocket.send_text(line) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Missing the type hint on
websocket
: