Skip to content

Simplest WebSockets example "fails" with a 403 #11340

Closed Answered by Kludex
dAnjou asked this question in Questions
Discussion options

You must be logged in to vote

Missing the type hint on websocket:

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)

Replies: 1 comment 2 replies

Comment options

Kludex
Mar 24, 2024
Collaborator Sponsor

You must be logged in to vote
2 replies
@dAnjou
Comment options

@Trolldemorted
Comment options

Answer selected by Kludex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
3 participants