Skip to content

📨 💽

🕐❔ 👆 💪 📨 📨 🏑 ↩️ 🎻, 👆 💪 ⚙️ Form.

Info

⚙️ 📨, 🥇 ❎ python-multipart.

🤶 Ⓜ. pip install python-multipart.

🗄 Form

🗄 Form ⚪️➡️ fastapi:

from fastapi import FastAPI, Form

app = FastAPI()


@app.post("/login/")
async def login(username: str = Form(), password: str = Form()):
    return {"username": username}
🤓 Other versions and variants
from typing import Annotated

from fastapi import FastAPI, Form

app = FastAPI()


@app.post("/login/")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
    return {"username": username}
from fastapi import FastAPI, Form
from typing_extensions import Annotated

app = FastAPI()


@app.post("/login/")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
    return {"username": username}

🔬 Form 🔢

✍ 📨 🔢 🎏 🌌 👆 🔜 Body ⚖️ Query:

from fastapi import FastAPI, Form

app = FastAPI()


@app.post("/login/")
async def login(username: str = Form(), password: str = Form()):
    return {"username": username}
🤓 Other versions and variants
from typing import Annotated

from fastapi import FastAPI, Form

app = FastAPI()


@app.post("/login/")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
    return {"username": username}
from fastapi import FastAPI, Form
from typing_extensions import Annotated

app = FastAPI()


@app.post("/login/")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
    return {"username": username}

🖼, 1️⃣ 🌌 Oauth2️⃣ 🔧 💪 ⚙️ (🤙 "🔐 💧") ⚫️ ✔ 📨 username & password 📨 🏑.

🔌 🚚 🏑 ⚫️❔ 📛 username & password, & 📨 📨 🏑, 🚫 🎻.

⏮️ Form 👆 💪 📣 🎏 📳 ⏮️ Body (& Query, Path, Cookie), 🔌 🔬, 🖼, 📛 (✅ user-name ↩️ username), ♒️.

Info

Form 🎓 👈 😖 🔗 ⚪️➡️ Body.

Tip

📣 📨 💪, 👆 💪 ⚙️ Form 🎯, ↩️ 🍵 ⚫️ 🔢 🔜 🔬 🔢 🔢 ⚖️ 💪 (🎻) 🔢.

🔃 "📨 🏑"

🌌 🕸 📨 (<form></form>) 📨 💽 💽 🛎 ⚙️ "🎁" 🔢 👈 📊, ⚫️ 🎏 ⚪️➡️ 🎻.

FastAPI 🔜 ⚒ 💭 ✍ 👈 📊 ⚪️➡️ ▶️️ 🥉 ↩️ 🎻.

📡 ℹ

📊 ⚪️➡️ 📨 🛎 🗜 ⚙️ "📻 🆎" application/x-www-form-urlencoded.

✋️ 🕐❔ 📨 🔌 📁, ⚫️ 🗜 multipart/form-data. 👆 🔜 ✍ 🔃 🚚 📁 ⏭ 📃.

🚥 👆 💚 ✍ 🌖 🔃 👉 🔢 & 📨 🏑, 👳 🏇 🕸 🩺 POST.

Warning

👆 💪 📣 💗 Form 🔢 ➡ 🛠️, ✋️ 👆 💪 🚫 📣 Body 🏑 👈 👆 ⌛ 📨 🎻, 📨 🔜 ✔️ 💪 🗜 ⚙️ application/x-www-form-urlencoded ↩️ application/json.

👉 🚫 🚫 FastAPI, ⚫️ 🍕 🇺🇸🔍 🛠️.

🌃

⚙️ Form 📣 📨 💽 🔢 🔢.