sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.

Home Page:https://sanic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to use response.stream in v23.6 or Or a new similar feature

Dr-lau opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

i want use return response.stream(
camera.stream,
content_type='multipart/x-mixed-replace; boundary=frame'
)
in my project, but in v23.6 this api has been removed , i do not know how to implement similar functions.
Can you help me?

Describe the solution you'd like

how to use response.stream in v23.6 or similar feature

Additional context

No response

Streaming the response the new way as in https://sanic.dev/en/guide/advanced/streaming.html#response-streaming

Something along these lines, adapt to your use case:

@app.route("/")
async def stream(request):
    response = await request.respond(content_type="multipart/x-mixed-replace; boundary=frame")
    async for frame in camera.stream:
        await response.send(frame)
commented

thanks,