mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-21 10:13:53 +08:00
18 lines
307 B
Python
18 lines
307 B
Python
from typing import Annotated
|
|
|
|
from fastapi import FastAPI, Form
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class FormData(BaseModel):
|
|
username: str
|
|
password: str
|
|
model_config = {"extra": "forbid"}
|
|
|
|
|
|
@app.post("/login/")
|
|
async def login(data: Annotated[FormData, Form()]):
|
|
return data
|