5.9 KiB
🛠️ FastAPI 🔛 🪔
👉 📄 👆 🔜 💡 ❔ 💪 🛠️ FastAPI 🈸 🔛 🪔 ⚙️ 🆓 📄. 👶
⚫️ 🔜 ✊ 👆 🔃 1️⃣0️⃣ ⏲.
!!! info 🪔 FastAPI 💰. 👶
🔰 FastAPI 📱
- ✍ 📁 👆 📱, 🖼,
./fastapideta/
& ⛔ 🔘 ⚫️.
FastAPI 📟
- ✍
main.py
📁 ⏮️:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
📄
🔜, 🎏 📁 ✍ 📁 requirements.txt
⏮️:
fastapi
!!! tip 👆 🚫 💪 ❎ Uvicorn 🛠️ 🔛 🪔, 👐 👆 🔜 🎲 💚 ❎ ⚫️ 🌐 💯 👆 📱.
📁 📊
👆 🔜 🔜 ✔️ 1️⃣ 📁 ./fastapideta/
⏮️ 2️⃣ 📁:
.
└── main.py
└── requirements.txt
✍ 🆓 🪔 🏧
🔜 ✍ 🆓 🏧 🔛 🪔, 👆 💪 📧 & 🔐.
👆 🚫 💪 💳.
❎ ✳
🕐 👆 ✔️ 👆 🏧, ❎ 🪔 ✳:
=== "💾, 🇸🇻"
<div class="termy">
```console
$ curl -fsSL https://get.deta.dev/cli.sh | sh
```
</div>
=== "🚪 📋"
<div class="termy">
```console
$ iwr https://get.deta.dev/cli.ps1 -useb | iex
```
</div>
⏮️ ❎ ⚫️, 📂 🆕 📶 👈 ❎ ✳ 🔍.
🆕 📶, ✔ 👈 ⚫️ ☑ ❎ ⏮️:
$ deta --help
Deta command line interface for managing deta micros.
Complete documentation available at https://docs.deta.sh
Usage:
deta [flags]
deta [command]
Available Commands:
auth Change auth settings for a deta micro
...
!!! tip 🚥 👆 ✔️ ⚠ ❎ ✳, ✅ 🛂 🪔 🩺.
💳 ⏮️ ✳
🔜 💳 🪔 ⚪️➡️ ✳ ⏮️:
$ deta login
Please, log in from the web page. Waiting..
Logged in successfully.
👉 🔜 📂 🕸 🖥 & 🔓 🔁.
🛠️ ⏮️ 🪔
⏭, 🛠️ 👆 🈸 ⏮️ 🪔 ✳:
$ deta new
Successfully created a new micro
// Notice the "endpoint" 🔍
{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}
Adding dependencies...
---> 100%
Successfully installed fastapi-0.61.1 pydantic-1.7.2 starlette-0.13.6
👆 🔜 👀 🎻 📧 🎏:
{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}
!!! tip
👆 🛠️ 🔜 ✔️ 🎏 "endpoint"
📛.
✅ ⚫️
🔜 📂 👆 🖥 👆 endpoint
📛. 🖼 🔛 ⚫️ https://qltnci.deta.dev
, ✋️ 👆 🔜 🎏.
👆 🔜 👀 🎻 📨 ⚪️➡️ 👆 FastAPI 📱:
{
"Hello": "World"
}
& 🔜 🚶 /docs
👆 🛠️, 🖼 🔛 ⚫️ 🔜 https://qltnci.deta.dev/docs
.
⚫️ 🔜 🎦 👆 🩺 💖:

🛠️ 📢 🔐
🔢, 🪔 🔜 🍵 🤝 ⚙️ 🍪 👆 🏧.
✋️ 🕐 👆 🔜, 👆 💪 ⚒ ⚫️ 📢 ⏮️:
$ deta auth disable
Successfully disabled http auth
🔜 👆 💪 💰 👈 📛 ⏮️ 🙆 & 👫 🔜 💪 🔐 👆 🛠️. 👶
🇺🇸🔍
㊗ ❗ 👆 🛠️ 👆 FastAPI 📱 🪔 ❗ 👶 👶
, 👀 👈 🪔 ☑ 🍵 🇺🇸🔍 👆, 👆 🚫 ✔️ ✊ 💅 👈 & 💪 💭 👈 👆 👩💻 🔜 ✔️ 🔐 🗜 🔗. 👶 👶
✅ 🕶
⚪️➡️ 👆 🩺 🎚 (👫 🔜 📛 💖 https://qltnci.deta.dev/docs
) 📨 📨 👆 ➡ 🛠️ /items/{item_id}
.
🖼 ⏮️ 🆔 5
.
🔜 🚶 https://web.deta.sh.
👆 🔜 👀 📤 📄 ◀️ 🤙 "◾" ⏮️ 🔠 👆 📱.
👆 🔜 👀 📑 ⏮️ "ℹ", & 📑 "🕶", 🚶 📑 "🕶".
📤 👆 💪 ✔ ⏮️ 📨 📨 👆 📱.
👆 💪 ✍ 👫 & 🏤-🤾 👫.

💡 🌅
☝, 👆 🔜 🎲 💚 🏪 💽 👆 📱 🌌 👈 😣 🔘 🕰. 👈 👆 💪 ⚙️ 🪔 🧢, ⚫️ ✔️ 👍 🆓 🎚.
👆 💪 ✍ 🌅 🪔 🩺.
🛠️ 🔧
👟 🔙 🔧 👥 🔬 🛠️ 🔧{.internal-link target=_blank}, 📥 ❔ 🔠 👫 🔜 🍵 ⏮️ 🪔:
- 🇺🇸🔍: 🍵 🪔, 👫 🔜 🤝 👆 📁 & 🍵 🇺🇸🔍 🔁.
- 🏃♂ 🔛 🕴: 🍵 🪔, 🍕 👫 🐕🦺.
- ⏏: 🍵 🪔, 🍕 👫 🐕🦺.
- 🧬: 🍵 🪔, 🍕 👫 🐕🦺.
- 💾: 📉 🔁 🪔, 👆 💪 📧 👫 📈 ⚫️.
- ⏮️ 🔁 ⏭ ▶️: 🚫 🔗 🐕🦺, 👆 💪 ⚒ ⚫️ 👷 ⏮️ 👫 💾 ⚙️ ⚖️ 🌖 ✍.
!!! note 🪔 🔧 ⚒ ⚫️ ⏩ (& 🆓) 🛠️ 🙅 🈸 🔜.
⚫️ 💪 📉 📚 ⚙️ 💼, ✋️ 🎏 🕰, ⚫️ 🚫 🐕🦺 🎏, 💖 ⚙️ 🔢 💽 (↖️ ⚪️➡️ 🪔 👍 ☁ 💽 ⚙️), 🛃 🕹 🎰, ♒️.
👆 💪 ✍ 🌅 ℹ <a href="https://docs.deta.sh/docs/micros/about/" class="external-link" target="_blank">🪔 🩺</a> 👀 🚥 ⚫️ ▶️️ ⚒ 👆.