fastapi-master/docs_src/request_forms_and_files/tutorial001.py

15 lines
317 B
Python
Raw Normal View History

2024-08-24 12:41:47 +08:00
from fastapi import FastAPI, File, Form, UploadFile
app = FastAPI()
@app.post("/files/")
async def create_file(
file: bytes = File(), fileb: UploadFile = File(), token: str = Form()
):
return {
"file_size": len(file),
"token": token,
"fileb_content_type": fileb.content_type,
}