diff --git a/docs/en/docs/advanced/custom-response.md b/docs/en/docs/advanced/custom-response.md index e53409c39d..9b3cbbc224 100644 --- a/docs/en/docs/advanced/custom-response.md +++ b/docs/en/docs/advanced/custom-response.md @@ -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 } diff --git a/docs_src/custom_response/tutorial007_py39.py b/docs_src/custom_response/tutorial007_py39.py index e2a53a2119..06c015ff31 100644 --- a/docs_src/custom_response/tutorial007_py39.py +++ b/docs_src/custom_response/tutorial007_py39.py @@ -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("/")