fastapi/docs_src/custom_response/tutorial007_py39.py

18 lines
326 B
Python

import asyncio
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 asyncio.sleep(0.1)
@app.get("/")
async def main():
return StreamingResponse(fake_video_streamer())