Coverage for docs_src / request_files / tutorial001_03_an_py310.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from typing import Annotated 1abcdefgh

2 

3from fastapi import FastAPI, File, UploadFile 1abcdefgh

4 

5app = FastAPI() 1abcdefgh

6 

7 

8@app.post("/files/") 1abcdefgh

9async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]): 1abcdefgh

10 return {"file_size": len(file)} 1ijkl

11 

12 

13@app.post("/uploadfile/") 1abcdefgh

14async def create_upload_file( 1abcdefgh

15 file: Annotated[UploadFile, File(description="A file read as UploadFile")], 

16): 

17 return {"filename": file.filename} 1mnop