fix StreamingResponse example

Fixes #14680
This commit is contained in:
Casper da Costa-Luis 2026-01-10 09:52:22 +00:00
parent f2687dc1bb
commit 1ca165c0c5
No known key found for this signature in database
GPG Key ID: D88C553DBD362CDE
2 changed files with 4 additions and 1 deletions

View File

@ -217,7 +217,7 @@ You can also use the `status_code` parameter combined with the `response_class`
Takes an async generator or a normal generator/iterator and streams the response body.
{* ../../docs_src/custom_response/tutorial007_py39.py hl[2,14] *}
{* ../../docs_src/custom_response/tutorial007_py39.py hl[4,17] *}
#### Using `StreamingResponse` with file-like objects { #using-streamingresponse-with-file-like-objects }

View File

@ -1,3 +1,5 @@
import asyncio
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
@ -7,6 +9,7 @@ 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("/")