Код: Выделить всё
from fastapi import FastAPI, UploadFile, Response
from typing import Optional
app = FastAPI()
@app.post('/grades')
async def request_legacy(
response: Response,
grade_file: UploadFile,
grade_email: Optional[str] = None
):
# Doing other stuff here unrelated, but eventually do:
print(f"Grade email: {grade_email}")
return {"Group": grade_email or ""}
Код: Выделить всё
import requests
api_url = "http://localhost:8000/grades"
with open("request.py", "rb") as f:
files = {'grade_file': f}
data = {'grade_email': "[email protected]"}
response = requests.post(api_url, files=files, data=data, verify=False)
print(response.json())
Я пробовал отправить его несколькими способами, но не понимаю, как это будет работать. Я проверил журналы на наличие ошибок и убедился, что использую правильный ключ для словаря в данных.
Подробнее здесь: https://stackoverflow.com/questions/790 ... il-paramet