mirror of https://github.com/tiangolo/fastapi.git
Merge 1ca165c0c5 into 5ca11c59e3
This commit is contained in:
commit
30aa5beccb
|
|
@ -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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -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("/")
|
||||
|
|
|
|||
Loading…
Reference in New Issue