mirror of https://github.com/tiangolo/fastapi.git
70 lines
2.6 KiB
Markdown
70 lines
2.6 KiB
Markdown
# 📨 📨 🔗
|
||
|
||
🕐❔ 👆 ✍ **FastAPI** *➡ 🛠️* 👆 💪 🛎 📨 🙆 📊 ⚪️➡️ ⚫️: `dict`, `list`, Pydantic 🏷, 💽 🏷, ♒️.
|
||
|
||
🔢, **FastAPI** 🔜 🔁 🗜 👈 📨 💲 🎻 ⚙️ `jsonable_encoder` 🔬 [🎻 🔗 🔢](../tutorial/encoder.md){.internal-link target=_blank}.
|
||
|
||
⤴️, ⛅ 🎑, ⚫️ 🔜 🚮 👈 🎻-🔗 💽 (✅ `dict`) 🔘 `JSONResponse` 👈 🔜 ⚙️ 📨 📨 👩💻.
|
||
|
||
✋️ 👆 💪 📨 `JSONResponse` 🔗 ⚪️➡️ 👆 *➡ 🛠️*.
|
||
|
||
⚫️ 💪 ⚠, 🖼, 📨 🛃 🎚 ⚖️ 🍪.
|
||
|
||
## 📨 `Response`
|
||
|
||
👐, 👆 💪 📨 🙆 `Response` ⚖️ 🙆 🎧-🎓 ⚫️.
|
||
|
||
/// tip
|
||
|
||
`JSONResponse` ⚫️ 🎧-🎓 `Response`.
|
||
|
||
///
|
||
|
||
& 🕐❔ 👆 📨 `Response`, **FastAPI** 🔜 🚶♀️ ⚫️ 🔗.
|
||
|
||
⚫️ 🏆 🚫 🙆 💽 🛠️ ⏮️ Pydantic 🏷, ⚫️ 🏆 🚫 🗜 🎚 🙆 🆎, ♒️.
|
||
|
||
👉 🤝 👆 📚 💪. 👆 💪 📨 🙆 📊 🆎, 🔐 🙆 💽 📄 ⚖️ 🔬, ♒️.
|
||
|
||
## ⚙️ `jsonable_encoder` `Response`
|
||
|
||
↩️ **FastAPI** 🚫 🙆 🔀 `Response` 👆 📨, 👆 ✔️ ⚒ 💭 ⚫️ 🎚 🔜 ⚫️.
|
||
|
||
🖼, 👆 🚫🔜 🚮 Pydantic 🏷 `JSONResponse` 🍵 🥇 🏭 ⚫️ `dict` ⏮️ 🌐 📊 🆎 (💖 `datetime`, `UUID`, ♒️) 🗜 🎻-🔗 🆎.
|
||
|
||
📚 💼, 👆 💪 ⚙️ `jsonable_encoder` 🗜 👆 📊 ⏭ 🚶♀️ ⚫️ 📨:
|
||
|
||
```Python hl_lines="6-7 21-22"
|
||
{!../../docs_src/response_directly/tutorial001.py!}
|
||
```
|
||
|
||
/// note | "📡 ℹ"
|
||
|
||
👆 💪 ⚙️ `from starlette.responses import JSONResponse`.
|
||
|
||
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃.
|
||
|
||
///
|
||
|
||
## 🛬 🛃 `Response`
|
||
|
||
🖼 🔛 🎦 🌐 🍕 👆 💪, ✋️ ⚫️ 🚫 📶 ⚠, 👆 💪 ✔️ 📨 `item` 🔗, & **FastAPI** 🔜 🚮 ⚫️ `JSONResponse` 👆, 🏭 ⚫️ `dict`, ♒️. 🌐 👈 🔢.
|
||
|
||
🔜, ➡️ 👀 ❔ 👆 💪 ⚙️ 👈 📨 🛃 📨.
|
||
|
||
➡️ 💬 👈 👆 💚 📨 <a href="https://en.wikipedia.org/wiki/XML" class="external-link" target="_blank">📂</a> 📨.
|
||
|
||
👆 💪 🚮 👆 📂 🎚 🎻, 🚮 ⚫️ `Response`, & 📨 ⚫️:
|
||
|
||
```Python hl_lines="1 18"
|
||
{!../../docs_src/response_directly/tutorial002.py!}
|
||
```
|
||
|
||
## 🗒
|
||
|
||
🕐❔ 👆 📨 `Response` 🔗 🚮 📊 🚫 ✔, 🗜 (🎻), 🚫 📄 🔁.
|
||
|
||
✋️ 👆 💪 📄 ⚫️ 🔬 [🌖 📨 🗄](additional-responses.md){.internal-link target=_blank}.
|
||
|
||
👆 💪 👀 ⏪ 📄 ❔ ⚙️/📣 👉 🛃 `Response`Ⓜ ⏪ ✔️ 🏧 💽 🛠️, 🧾, ♒️.
|