4.3 KiB
🏃 💽 ❎ - Uvicorn
👑 👜 👆 💪 🏃 FastAPI 🈸 🛰 💽 🎰 🔫 💽 📋 💖 Uvicorn.
📤 3️⃣ 👑 🎛:
💽 🎰 & 💽 📋
📤 🤪 ℹ 🔃 📛 ✔️ 🤯. 👶
🔤 "💽" 🛎 ⚙️ 🔗 👯♂️ 🛰/☁ 💻 (⚛ ⚖️ 🕹 🎰) & 📋 👈 🏃♂ 🔛 👈 🎰 (✅ 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 ⚓️ 🔛 AnyIO, ❔ ⚒ 👫 🔗 ⏮️ 👯♂️ 🐍 🐩 🗃 ✳ & 🎻.
👐, Uvicorn ⏳ 🕴 🔗 ⏮️ ✳, & ⚫️ 🛎 ⚙️ uvloop
, ↕-🎭 💧-♻ asyncio
.
✋️ 🚥 👆 💚 🔗 ⚙️ 🎻, ⤴️ 👆 💪 ⚙️ Hypercorn ⚫️ 🐕🦺 ⚫️. 👶
❎ Hypercorn ⏮️ 🎻
🥇 👆 💪 ❎ Hypercorn ⏮️ 🎻 🐕🦺:
$ pip install "hypercorn[trio]"
---> 100%
🏃 ⏮️ 🎻
⤴️ 👆 💪 🚶♀️ 📋 ⏸ 🎛 --worker-class
⏮️ 💲 trio
:
$ hypercorn main:app --worker-class trio
& 👈 🔜 ▶️ Hypercorn ⏮️ 👆 📱 ⚙️ 🎻 👩💻.
🔜 👆 💪 ⚙️ 🎻 🔘 👆 📱. ⚖️ 👍, 👆 💪 ⚙️ AnyIO, 🚧 👆 📟 🔗 ⏮️ 👯♂️ 🎻 & ✳. 👶
🛠️ 🔧
👫 🖼 🏃 💽 📋 (📧.Ⓜ Uvicorn), ▶️ 👁 🛠️, 👂 🔛 🌐 📢 (0.0.0.0
) 🔛 🔁 ⛴ (✅ 80
).
👉 🔰 💭. ✋️ 👆 🔜 🎲 💚 ✊ 💅 🌖 👜, 💖:
- 💂♂ - 🇺🇸🔍
- 🏃♂ 🔛 🕴
- ⏏
- 🧬 (🔢 🛠️ 🏃)
- 💾
- ⏮️ 🔁 ⏭ ▶️
👤 🔜 💬 👆 🌅 🔃 🔠 👫 🔧, ❔ 💭 🔃 👫, & 🧱 🖼 ⏮️ 🎛 🍵 👫 ⏭ 📃. 👶