mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-24 16:29:41 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
committed by
GitHub
parent
d06ab3f5c7
commit
c9e2277d8b
16
docs_src/request_form_models/tutorial001_an_py310.py
Normal file
16
docs_src/request_form_models/tutorial001_an_py310.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import FastAPI, Form
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FormData(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
|
||||
@app.post("/login/")
|
||||
async def login(data: Annotated[FormData, Form()]):
|
||||
return data
|
||||
14
docs_src/request_form_models/tutorial001_py310.py
Normal file
14
docs_src/request_form_models/tutorial001_py310.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from fastapi import FastAPI, Form
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FormData(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
|
||||
@app.post("/login/")
|
||||
async def login(data: FormData = Form()):
|
||||
return data
|
||||
17
docs_src/request_form_models/tutorial002_an_py310.py
Normal file
17
docs_src/request_form_models/tutorial002_an_py310.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
15
docs_src/request_form_models/tutorial002_py310.py
Normal file
15
docs_src/request_form_models/tutorial002_py310.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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: FormData = Form()):
|
||||
return data
|
||||
Reference in New Issue
Block a user