5.0 KiB
💪 - 💗 🔢
🔜 👈 👥 ✔️ 👀 ❔ ⚙️ Path
& Query
, ➡️ 👀 🌅 🏧 ⚙️ 📨 💪 📄.
🌀 Path
, Query
& 💪 🔢
🥇, ↗️, 👆 💪 🌀 Path
, Query
& 📨 💪 🔢 📄 ➡ & FastAPI 🔜 💭 ⚫️❔.
& 👆 💪 📣 💪 🔢 📦, ⚒ 🔢 None
:
=== "🐍 3️⃣.6️⃣ & 🔛"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ & 🔛"
```Python hl_lines="17-19"
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
!!! note
👀 👈, 👉 💼, item
👈 🔜 ✊ ⚪️➡️ 💪 📦. ⚫️ ✔️ None
🔢 💲.
💗 💪 🔢
⏮️ 🖼, ➡ 🛠️ 🔜 ⌛ 🎻 💪 ⏮️ 🔢 Item
, 💖:
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
✋️ 👆 💪 📣 💗 💪 🔢, ✅ item
& user
:
=== "🐍 3️⃣.6️⃣ & 🔛"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ & 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
👉 💼, FastAPI 🔜 👀 👈 📤 🌅 🌘 1️⃣ 💪 🔢 🔢 (2️⃣ 🔢 👈 Pydantic 🏷).
, ⚫️ 🔜 ⤴️ ⚙️ 🔢 📛 🔑 (🏑 📛) 💪, & ⌛ 💪 💖:
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
},
"user": {
"username": "dave",
"full_name": "Dave Grohl"
}
}
!!! note
👀 👈 ✋️ item
📣 🎏 🌌 ⏭, ⚫️ 🔜 ⌛ 🔘 💪 ⏮️ 🔑 item
.
FastAPI 🔜 🏧 🛠️ ⚪️➡️ 📨, 👈 🔢 item
📨 ⚫️ 🎯 🎚 & 🎏 user
.
⚫️ 🔜 🎭 🔬 ⚗ 💽, & 🔜 📄 ⚫️ 💖 👈 🗄 🔗 & 🏧 🩺.
⭐ 💲 💪
🎏 🌌 📤 Query
& Path
🔬 ➕ 💽 🔢 & ➡ 🔢, FastAPI 🚚 🌓 Body
.
🖼, ↔ ⏮️ 🏷, 👆 💪 💭 👈 👆 💚 ✔️ ➕1️⃣ 🔑 importance
🎏 💪, 🥈 item
& user
.
🚥 👆 📣 ⚫️, ↩️ ⚫️ ⭐ 💲, FastAPI 🔜 🤔 👈 ⚫️ 🔢 🔢.
✋️ 👆 💪 💡 FastAPI 😥 ⚫️ ➕1️⃣ 💪 🔑 ⚙️ Body
:
=== "🐍 3️⃣.6️⃣ & 🔛"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial003.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ & 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
👉 💼, FastAPI 🔜 ⌛ 💪 💖:
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
},
"user": {
"username": "dave",
"full_name": "Dave Grohl"
},
"importance": 5
}
🔄, ⚫️ 🔜 🗜 📊 🆎, ✔, 📄, ♒️.
💗 💪 = & 🔢
↗️, 👆 💪 📣 🌖 🔢 🔢 🕐❔ 👆 💪, 🌖 🙆 💪 🔢.
, 🔢, ⭐ 💲 🔬 🔢 🔢, 👆 🚫 ✔️ 🎯 🚮 Query
, 👆 💪:
q: Union[str, None] = None
⚖️ 🐍 3️⃣.1️⃣0️⃣ & 🔛:
q: str | None = None
🖼:
=== "🐍 3️⃣.6️⃣ & 🔛"
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ & 🔛"
```Python hl_lines="26"
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
!!! info
Body
✔️ 🌐 🎏 ➕ 🔬 & 🗃 🔢 Query
,Path
& 🎏 👆 🔜 👀 ⏪.
⏯ 👁 💪 🔢
➡️ 💬 👆 🕴 ✔️ 👁 item
💪 🔢 ⚪️➡️ Pydantic 🏷 Item
.
🔢, FastAPI 🔜 ⤴️ ⌛ 🚮 💪 🔗.
✋️ 🚥 👆 💚 ⚫️ ⌛ 🎻 ⏮️ 🔑 item
& 🔘 ⚫️ 🏷 🎚, ⚫️ 🔨 🕐❔ 👆 📣 ➕ 💪 🔢, 👆 💪 ⚙️ 🎁 Body
🔢 embed
:
item: Item = Body(embed=True)
:
=== "🐍 3️⃣.6️⃣ & 🔛"
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ & 🔛"
```Python hl_lines="15"
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
👉 💼 FastAPI 🔜 ⌛ 💪 💖:
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
}
↩️:
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
🌃
👆 💪 🚮 💗 💪 🔢 👆 ➡ 🛠️ 🔢, ✋️ 📨 💪 🕴 ✔️ 👁 💪.
✋️ FastAPI 🔜 🍵 ⚫️, 🤝 👆 ☑ 📊 👆 🔢, & ✔ & 📄 ☑ 🔗 ➡ 🛠️.
👆 💪 📣 ⭐ 💲 📨 🍕 💪.
& 👆 💪 💡 FastAPI ⏯ 💪 🔑 🕐❔ 📤 🕴 👁 🔢 📣.