前言
路径函数混合使用 Form、File
from fastapi import FastAPI, File, Form, UploadFile
app = FastAPI()
@app.post("/files/")
async def create_file(
file: bytes = File(...),
file_b: UploadFile = File(...),
token: str = Form(...)
):
return {
"file_size": len(file),
"file_b_content_type": file_b.content_type,
"token": token
}
if __name__ == "__main__":
uvicorn.run(app="21_File:app", host="127.0.0.1", port=8080, reload=