Debian Codegraph @

docs_src/custom_response/tutorial007_py310.py

raw
1 import anyio
2 from fastapi import FastAPI
3 from fastapi.responses import StreamingResponse
4
5 app = FastAPI()
6
7
8 async def fake_video_streamer():
9 for i in range(10):
10 yield b"some fake video bytes"
11 await anyio.sleep(0)
12
13
14 @app.get("/")
15 async def main():
16 return StreamingResponse(fake_video_streamer())