mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-28 04:36:14 -05:00
📝 Update docs for responses and new stream with yield (#15023)
This commit is contained in:
committed by
GitHub
parent
c0836dc1b7
commit
1377052c6c
@@ -22,23 +22,33 @@ class PNGStreamingResponse(StreamingResponse):
|
||||
|
||||
@app.get("/image/stream", response_class=PNGStreamingResponse)
|
||||
async def stream_image() -> AsyncIterable[bytes]:
|
||||
for chunk in read_image():
|
||||
yield chunk
|
||||
with read_image() as image_file:
|
||||
for chunk in image_file:
|
||||
yield chunk
|
||||
|
||||
|
||||
@app.get("/image/stream-no-async", response_class=PNGStreamingResponse)
|
||||
def stream_image_no_async() -> Iterable[bytes]:
|
||||
for chunk in read_image():
|
||||
yield chunk
|
||||
with read_image() as image_file:
|
||||
for chunk in image_file:
|
||||
yield chunk
|
||||
|
||||
|
||||
@app.get("/image/stream-no-async-yield-from", response_class=PNGStreamingResponse)
|
||||
def stream_image_no_async_yield_from() -> Iterable[bytes]:
|
||||
with read_image() as image_file:
|
||||
yield from image_file
|
||||
|
||||
|
||||
@app.get("/image/stream-no-annotation", response_class=PNGStreamingResponse)
|
||||
async def stream_image_no_annotation():
|
||||
for chunk in read_image():
|
||||
yield chunk
|
||||
with read_image() as image_file:
|
||||
for chunk in image_file:
|
||||
yield chunk
|
||||
|
||||
|
||||
@app.get("/image/stream-no-async-no-annotation", response_class=PNGStreamingResponse)
|
||||
def stream_image_no_async_no_annotation():
|
||||
for chunk in read_image():
|
||||
yield chunk
|
||||
with read_image() as image_file:
|
||||
for chunk in image_file:
|
||||
yield chunk
|
||||
|
||||
Reference in New Issue
Block a user