Files
fastapi/docs_src/custom_response/tutorial007_py310.py
Casper da Costa-Luis c3f54a0794 📝 Add await in StreamingResponse code example to allow cancellation (#14681)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2026-02-27 19:12:46 +00:00

17 lines
319 B
Python

import anyio
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
app = FastAPI()
async def fake_video_streamer():
for i in range(10):
yield b"some fake video bytes"
await anyio.sleep(0)
@app.get("/")
async def main():
return StreamingResponse(fake_video_streamer())