mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 05:15:46 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
committed by
GitHub
parent
d06ab3f5c7
commit
c9e2277d8b
14
docs_src/custom_response/tutorial008_py310.py
Normal file
14
docs_src/custom_response/tutorial008_py310.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
some_file_path = "large-video-file.mp4"
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def main():
|
||||
def iterfile(): # (1)
|
||||
with open(some_file_path, mode="rb") as file_like: # (2)
|
||||
yield from file_like # (3)
|
||||
|
||||
return StreamingResponse(iterfile(), media_type="video/mp4")
|
||||
Reference in New Issue
Block a user