mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-26 06:51:40 -05:00
* 🌐 💬 🩺 🦲 * 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks * 🛠️😊 * ♻️ Rename emoji lang from emj to em, and main docs name as 😉 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Axd1x8a <26704473+FeeeeK@users.noreply.github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
113 lines
2.1 KiB
Markdown
113 lines
2.1 KiB
Markdown
# 🛠️
|
||
|
||
👆 💪 🔗 🕹 👆 👨🎨, 🖼 ⏮️ 🎙 🎙 📟 ⚖️ 🗒.
|
||
|
||
## 🤙 `uvicorn`
|
||
|
||
👆 FastAPI 🈸, 🗄 & 🏃 `uvicorn` 🔗:
|
||
|
||
```Python hl_lines="1 15"
|
||
{!../../../docs_src/debugging/tutorial001.py!}
|
||
```
|
||
|
||
### 🔃 `__name__ == "__main__"`
|
||
|
||
👑 🎯 `__name__ == "__main__"` ✔️ 📟 👈 🛠️ 🕐❔ 👆 📁 🤙 ⏮️:
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ python myapp.py
|
||
```
|
||
|
||
</div>
|
||
|
||
✋️ 🚫 🤙 🕐❔ ➕1️⃣ 📁 🗄 ⚫️, 💖:
|
||
|
||
```Python
|
||
from myapp import app
|
||
```
|
||
|
||
#### 🌅 ℹ
|
||
|
||
➡️ 💬 👆 📁 🌟 `myapp.py`.
|
||
|
||
🚥 👆 🏃 ⚫️ ⏮️:
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ python myapp.py
|
||
```
|
||
|
||
</div>
|
||
|
||
⤴️ 🔗 🔢 `__name__` 👆 📁, ✍ 🔁 🐍, 🔜 ✔️ 💲 🎻 `"__main__"`.
|
||
|
||
, 📄:
|
||
|
||
```Python
|
||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||
```
|
||
|
||
🔜 🏃.
|
||
|
||
---
|
||
|
||
👉 🏆 🚫 🔨 🚥 👆 🗄 👈 🕹 (📁).
|
||
|
||
, 🚥 👆 ✔️ ➕1️⃣ 📁 `importer.py` ⏮️:
|
||
|
||
```Python
|
||
from myapp import app
|
||
|
||
# Some more code
|
||
```
|
||
|
||
👈 💼, 🏧 🔢 🔘 `myapp.py` 🔜 🚫 ✔️ 🔢 `__name__` ⏮️ 💲 `"__main__"`.
|
||
|
||
, ⏸:
|
||
|
||
```Python
|
||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||
```
|
||
|
||
🔜 🚫 🛠️.
|
||
|
||
!!! info
|
||
🌅 ℹ, ✅ <a href="https://docs.python.org/3/library/__main__.html" class="external-link" target="_blank">🛂 🐍 🩺</a>.
|
||
|
||
## 🏃 👆 📟 ⏮️ 👆 🕹
|
||
|
||
↩️ 👆 🏃 Uvicorn 💽 🔗 ⚪️➡️ 👆 📟, 👆 💪 🤙 👆 🐍 📋 (👆 FastAPI 🈸) 🔗 ⚪️➡️ 🕹.
|
||
|
||
---
|
||
|
||
🖼, 🎙 🎙 📟, 👆 💪:
|
||
|
||
* 🚶 "ℹ" 🎛.
|
||
* "🚮 📳...".
|
||
* 🖊 "🐍"
|
||
* 🏃 🕹 ⏮️ 🎛 "`Python: Current File (Integrated Terminal)`".
|
||
|
||
⚫️ 🔜 ⤴️ ▶️ 💽 ⏮️ 👆 **FastAPI** 📟, ⛔️ 👆 0️⃣, ♒️.
|
||
|
||
📥 ❔ ⚫️ 💪 👀:
|
||
|
||
<img src="/img/tutorial/debugging/image01.png">
|
||
|
||
---
|
||
|
||
🚥 👆 ⚙️ 🗒, 👆 💪:
|
||
|
||
* 📂 "🏃" 🍣.
|
||
* 🖊 🎛 "ℹ...".
|
||
* ⤴️ 🔑 🍣 🎦 🆙.
|
||
* 🖊 📁 ℹ (👉 💼, `main.py`).
|
||
|
||
⚫️ 🔜 ⤴️ ▶️ 💽 ⏮️ 👆 **FastAPI** 📟, ⛔️ 👆 0️⃣, ♒️.
|
||
|
||
📥 ❔ ⚫️ 💪 👀:
|
||
|
||
<img src="/img/tutorial/debugging/image02.png">
|