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

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from typing import Annotated 1abcd

2 

3from fastapi import FastAPI, File, UploadFile 1abcd

4 

5app = FastAPI() 1abcd

6 

7 

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

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

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

11 

12 

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

14async def create_upload_file( 1abcd

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

16): 

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