Mixing Http and Websockets in Python Quart

82 Views Asked by At

So my application needed to employ both a RESTful backend and a websockets backend. So I switched my API from Flask to Quart. However, even when following the docs to word the issue remains.

@app.websocket("/gen-image")
async def gen_image_ws():
    while True:
        data = await websocket.receive()
        if data == "Hello":
            await websocket.send("World")


@app.route("/gen-image", methods=["GET", "POST"])
async def gen_image():
    ...

But I get a bad handshake error

Starting WebSocket connection to ws://localhost:5500/gen-image
websocket: bad handshake

What am I doing wrong?

0

There are 0 best solutions below