Files
fastapi/docs_src/request_form_models/tutorial001_an.py
T
Sebastián Ramírez 7bad7c0975 ✨ Add support for Pydantic models in Form parameters (#12129)
Revert "⏪️ Temporarily revert "✨ Add support for Pydantic models in `Form` pa…"

This reverts commit 8e6cf9ee9c.
2024-09-05 17:16:50 +02:00

16 lines
278 B
Python

from fastapi import FastAPI, Form
from pydantic import BaseModel
from typing_extensions import Annotated
app = FastAPI()
class FormData(BaseModel):
username: str
password: str
@app.post("/login/")
async def login(data: Annotated[FormData, Form()]):
return data