mirror of https://github.com/tiangolo/fastapi.git
146 lines
4.3 KiB
Markdown
146 lines
4.3 KiB
Markdown
# 🏃 💽 ❎ - Uvicorn
|
||
|
||
👑 👜 👆 💪 🏃 **FastAPI** 🈸 🛰 💽 🎰 🔫 💽 📋 💖 **Uvicorn**.
|
||
|
||
📤 3️⃣ 👑 🎛:
|
||
|
||
* <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>: ↕ 🎭 🔫 💽.
|
||
* <a href="https://pgjones.gitlab.io/hypercorn/" class="external-link" target="_blank">Hypercorn</a>: 🔫 💽 🔗 ⏮️ 🇺🇸🔍/2️⃣ & 🎻 👪 🎏 ⚒.
|
||
* <a href="https://github.com/django/daphne" class="external-link" target="_blank">👸</a>: 🔫 💽 🏗 ✳ 📻.
|
||
|
||
## 💽 🎰 & 💽 📋
|
||
|
||
📤 🤪 ℹ 🔃 📛 ✔️ 🤯. 👶
|
||
|
||
🔤 "**💽**" 🛎 ⚙️ 🔗 👯♂️ 🛰/☁ 💻 (⚛ ⚖️ 🕹 🎰) & 📋 👈 🏃♂ 🔛 👈 🎰 (✅ Uvicorn).
|
||
|
||
✔️ 👈 🤯 🕐❔ 👆 ✍ "💽" 🏢, ⚫️ 💪 🔗 1️⃣ 📚 2️⃣ 👜.
|
||
|
||
🕐❔ 🔗 🛰 🎰, ⚫️ ⚠ 🤙 ⚫️ **💽**, ✋️ **🎰**, **💾** (🕹 🎰), **🕸**. 👈 🌐 🔗 🆎 🛰 🎰, 🛎 🏃♂ 💾, 🌐❔ 👆 🏃 📋.
|
||
|
||
## ❎ 💽 📋
|
||
|
||
👆 💪 ❎ 🔫 🔗 💽 ⏮️:
|
||
|
||
=== "Uvicorn"
|
||
|
||
* <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>, 🌩-⏩ 🔫 💽, 🏗 🔛 uvloop & httptool.
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ pip install "uvicorn[standard]"
|
||
|
||
---> 100%
|
||
```
|
||
|
||
</div>
|
||
|
||
!!! tip
|
||
❎ `standard`, Uvicorn 🔜 ❎ & ⚙️ 👍 ➕ 🔗.
|
||
|
||
👈 ✅ `uvloop`, ↕-🎭 💧-♻ `asyncio`, 👈 🚚 🦏 🛠️ 🎭 📈.
|
||
|
||
=== "Hypercorn"
|
||
|
||
* <a href="https://gitlab.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>, 🔫 💽 🔗 ⏮️ 🇺🇸🔍/2️⃣.
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ pip install hypercorn
|
||
|
||
---> 100%
|
||
```
|
||
|
||
</div>
|
||
|
||
...⚖️ 🙆 🎏 🔫 💽.
|
||
|
||
## 🏃 💽 📋
|
||
|
||
👆 💪 ⤴️ 🏃 👆 🈸 🎏 🌌 👆 ✔️ ⌛ 🔰, ✋️ 🍵 `--reload` 🎛, ✅:
|
||
|
||
=== "Uvicorn"
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ uvicorn main:app --host 0.0.0.0 --port 80
|
||
|
||
<span style="color: green;">INFO</span>: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
|
||
```
|
||
|
||
</div>
|
||
|
||
=== "Hypercorn"
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ hypercorn main:app --bind 0.0.0.0:80
|
||
|
||
Running on 0.0.0.0:8080 over http (CTRL + C to quit)
|
||
```
|
||
|
||
</div>
|
||
|
||
!!! warning
|
||
💭 ❎ `--reload` 🎛 🚥 👆 ⚙️ ⚫️.
|
||
|
||
`--reload` 🎛 🍴 🌅 🌅 ℹ, 🌅 ⚠, ♒️.
|
||
|
||
⚫️ ℹ 📚 ⏮️ **🛠️**, ✋️ 👆 **🚫🔜 🚫** ⚙️ ⚫️ **🏭**.
|
||
|
||
## Hypercorn ⏮️ 🎻
|
||
|
||
💃 & **FastAPI** ⚓️ 🔛 <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a>, ❔ ⚒ 👫 🔗 ⏮️ 👯♂️ 🐍 🐩 🗃 <a href="https://docs.python.org/3/library/asyncio-task.html" class="external-link" target="_blank">✳</a> & <a href="https://trio.readthedocs.io/en/stable/" class="external-link" target="_blank">🎻</a>.
|
||
|
||
👐, Uvicorn ⏳ 🕴 🔗 ⏮️ ✳, & ⚫️ 🛎 ⚙️ <a href="https://github.com/MagicStack/uvloop" class="external-link" target="_blank">`uvloop`</a>, ↕-🎭 💧-♻ `asyncio`.
|
||
|
||
✋️ 🚥 👆 💚 🔗 ⚙️ **🎻**, ⤴️ 👆 💪 ⚙️ **Hypercorn** ⚫️ 🐕🦺 ⚫️. 👶
|
||
|
||
### ❎ Hypercorn ⏮️ 🎻
|
||
|
||
🥇 👆 💪 ❎ Hypercorn ⏮️ 🎻 🐕🦺:
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ pip install "hypercorn[trio]"
|
||
---> 100%
|
||
```
|
||
|
||
</div>
|
||
|
||
### 🏃 ⏮️ 🎻
|
||
|
||
⤴️ 👆 💪 🚶♀️ 📋 ⏸ 🎛 `--worker-class` ⏮️ 💲 `trio`:
|
||
|
||
<div class="termy">
|
||
|
||
```console
|
||
$ hypercorn main:app --worker-class trio
|
||
```
|
||
|
||
</div>
|
||
|
||
& 👈 🔜 ▶️ Hypercorn ⏮️ 👆 📱 ⚙️ 🎻 👩💻.
|
||
|
||
🔜 👆 💪 ⚙️ 🎻 🔘 👆 📱. ⚖️ 👍, 👆 💪 ⚙️ AnyIO, 🚧 👆 📟 🔗 ⏮️ 👯♂️ 🎻 & ✳. 👶
|
||
|
||
## 🛠️ 🔧
|
||
|
||
👫 🖼 🏃 💽 📋 (📧.Ⓜ Uvicorn), ▶️ **👁 🛠️**, 👂 🔛 🌐 📢 (`0.0.0.0`) 🔛 🔁 ⛴ (✅ `80`).
|
||
|
||
👉 🔰 💭. ✋️ 👆 🔜 🎲 💚 ✊ 💅 🌖 👜, 💖:
|
||
|
||
* 💂♂ - 🇺🇸🔍
|
||
* 🏃♂ 🔛 🕴
|
||
* ⏏
|
||
* 🧬 (🔢 🛠️ 🏃)
|
||
* 💾
|
||
* ⏮️ 🔁 ⏭ ▶️
|
||
|
||
👤 🔜 💬 👆 🌅 🔃 🔠 👫 🔧, ❔ 💭 🔃 👫, & 🧱 🖼 ⏮️ 🎛 🍵 👫 ⏭ 📃. 👶
|