mirror of https://github.com/tiangolo/fastapi.git
74 lines
2.4 KiB
Markdown
74 lines
2.4 KiB
Markdown
# 🎧 🈸 - 🗻
|
||
|
||
🚥 👆 💪 ✔️ 2️⃣ 🔬 FastAPI 🈸, ⏮️ 👫 👍 🔬 🗄 & 👫 👍 🩺 ⚜, 👆 💪 ✔️ 👑 📱 & "🗻" 1️⃣ (⚖️ 🌅) 🎧-🈸(Ⓜ).
|
||
|
||
## 🗜 **FastAPI** 🈸
|
||
|
||
"🗜" ⛓ ❎ 🍕 "🔬" 🈸 🎯 ➡, 👈 ⤴️ ✊ 💅 🚚 🌐 🔽 👈 ➡, ⏮️ _➡ 🛠️_ 📣 👈 🎧-🈸.
|
||
|
||
### 🔝-🎚 🈸
|
||
|
||
🥇, ✍ 👑, 🔝-🎚, **FastAPI** 🈸, & 🚮 *➡ 🛠️*:
|
||
|
||
```Python hl_lines="3 6-8"
|
||
{!../../docs_src/sub_applications/tutorial001.py!}
|
||
```
|
||
|
||
### 🎧-🈸
|
||
|
||
⤴️, ✍ 👆 🎧-🈸, & 🚮 *➡ 🛠️*.
|
||
|
||
👉 🎧-🈸 ➕1️⃣ 🐩 FastAPI 🈸, ✋️ 👉 1️⃣ 👈 🔜 "🗻":
|
||
|
||
```Python hl_lines="11 14-16"
|
||
{!../../docs_src/sub_applications/tutorial001.py!}
|
||
```
|
||
|
||
### 🗻 🎧-🈸
|
||
|
||
👆 🔝-🎚 🈸, `app`, 🗻 🎧-🈸, `subapi`.
|
||
|
||
👉 💼, ⚫️ 🔜 📌 ➡ `/subapi`:
|
||
|
||
```Python hl_lines="11 19"
|
||
{!../../docs_src/sub_applications/tutorial001.py!}
|
||
```
|
||
|
||
### ✅ 🏧 🛠️ 🩺
|
||
|
||
🔜, 🏃 `uvicorn` ⏮️ 👑 📱, 🚥 👆 📁 `main.py`, ⚫️ 🔜:
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ uvicorn main:app --reload
|
||
|
||
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
|
||
```
|
||
|
||
</div>
|
||
|
||
& 📂 🩺 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
|
||
|
||
👆 🔜 👀 🏧 🛠️ 🩺 👑 📱, 🔌 🕴 🚮 👍 _➡ 🛠️_:
|
||
|
||
<img src="/img/tutorial/sub-applications/image01.png">
|
||
|
||
& ⤴️, 📂 🩺 🎧-🈸, <a href="http://127.0.0.1:8000/subapi/docs" class="external-link" target="_blank">http://127.0.0.1:8000/subapi/docs</a>.
|
||
|
||
👆 🔜 👀 🏧 🛠️ 🩺 🎧-🈸, ✅ 🕴 🚮 👍 _➡ 🛠️_, 🌐 🔽 ☑ 🎧-➡ 🔡 `/subapi`:
|
||
|
||
<img src="/img/tutorial/sub-applications/image02.png">
|
||
|
||
🚥 👆 🔄 🔗 ⏮️ 🙆 2️⃣ 👩💻 🔢, 👫 🔜 👷 ☑, ↩️ 🖥 🔜 💪 💬 🔠 🎯 📱 ⚖️ 🎧-📱.
|
||
|
||
### 📡 ℹ: `root_path`
|
||
|
||
🕐❔ 👆 🗻 🎧-🈸 🔬 🔛, FastAPI 🔜 ✊ 💅 🔗 🗻 ➡ 🎧-🈸 ⚙️ 🛠️ ⚪️➡️ 🔫 🔧 🤙 `root_path`.
|
||
|
||
👈 🌌, 🎧-🈸 🔜 💭 ⚙️ 👈 ➡ 🔡 🩺 🎚.
|
||
|
||
& 🎧-🈸 💪 ✔️ 🚮 👍 📌 🎧-🈸 & 🌐 🔜 👷 ☑, ↩️ FastAPI 🍵 🌐 👉 `root_path`Ⓜ 🔁.
|
||
|
||
👆 🔜 💡 🌅 🔃 `root_path` & ❔ ⚙️ ⚫️ 🎯 📄 🔃 [⛅ 🗳](behind-a-proxy.md){.internal-link target=_blank}.
|