mirror of
https://github.com/fastapi/fastapi.git
synced 2026-09-13 05:50:15 -04:00
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
17 lines
319 B
Python
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())
|