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}

🔬 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}

🖼, 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 📣 📨 💽 🔢 🔢.