🦏 🈸 - 💗 📁¶
🚥 👆 🏗 🈸 ⚖️ 🕸 🛠️, ⚫️ 🛎 💼 👈 👆 💪 🚮 🌐 🔛 👁 📁.
FastAPI 🚚 🏪 🧰 📊 👆 🈸 ⏪ 🚧 🌐 💪.
Info
🚥 👆 👟 ⚪️➡️ 🏺, 👉 🔜 🌓 🏺 📗.
🖼 📁 📊¶
➡️ 💬 👆 ✔️ 📁 📊 💖 👉:
.
├── app
│ ├── __init__.py
│ ├── main.py
│ ├── dependencies.py
│ └── routers
│ │ ├── __init__.py
│ │ ├── items.py
│ │ └── users.py
│ └── internal
│ ├── __init__.py
│ └── admin.py
Tip
📤 📚 __init__.py
📁: 1️⃣ 🔠 📁 ⚖️ 📁.
👉 ⚫️❔ ✔ 🏭 📟 ⚪️➡️ 1️⃣ 📁 🔘 ➕1️⃣.
🖼, app/main.py
👆 💪 ✔️ ⏸ 💖:
from app.routers import items
app
📁 🔌 🌐. & ⚫️ ✔️ 🛁 📁app/__init__.py
, ⚫️ "🐍 📦" (🗃 "🐍 🕹"):app
.- ⚫️ 🔌
app/main.py
📁. ⚫️ 🔘 🐍 📦 (📁 ⏮️ 📁__init__.py
), ⚫️ "🕹" 👈 📦:app.main
. - 📤
app/dependencies.py
📁, 💖app/main.py
, ⚫️ "🕹":app.dependencies
. - 📤 📁
app/routers/
⏮️ ➕1️⃣ 📁__init__.py
, ⚫️ "🐍 📦":app.routers
. - 📁
app/routers/items.py
🔘 📦,app/routers/
,, ⚫️ 🔁:app.routers.items
. - 🎏 ⏮️
app/routers/users.py
, ⚫️ ➕1️⃣ 🔁:app.routers.users
. - 📤 📁
app/internal/
⏮️ ➕1️⃣ 📁__init__.py
, ⚫️ ➕1️⃣ "🐍 📦":app.internal
. - & 📁
app/internal/admin.py
➕1️⃣ 🔁:app.internal.admin
.
🎏 📁 📊 ⏮️ 🏤:
.
├── app # "app" is a Python package
│ ├── __init__.py # this file makes "app" a "Python package"
│ ├── main.py # "main" module, e.g. import app.main
│ ├── dependencies.py # "dependencies" module, e.g. import app.dependencies
│ └── routers # "routers" is a "Python subpackage"
│ │ ├── __init__.py # makes "routers" a "Python subpackage"
│ │ ├── items.py # "items" submodule, e.g. import app.routers.items
│ │ └── users.py # "users" submodule, e.g. import app.routers.users
│ └── internal # "internal" is a "Python subpackage"
│ ├── __init__.py # makes "internal" a "Python subpackage"
│ └── admin.py # "admin" submodule, e.g. import app.internal.admin
APIRouter
¶
➡️ 💬 📁 💡 🚚 👩💻 🔁 /app/routers/users.py
.
👆 💚 ✔️ ➡ 🛠️ 🔗 👆 👩💻 👽 ⚪️➡️ 🎂 📟, 🚧 ⚫️ 🏗.
✋️ ⚫️ 🍕 🎏 FastAPI 🈸/🕸 🛠️ (⚫️ 🍕 🎏 "🐍 📦").
👆 💪 ✍ ➡ 🛠️ 👈 🕹 ⚙️ APIRouter
.
🗄 APIRouter
¶
👆 🗄 ⚫️ & ✍ "👐" 🎏 🌌 👆 🔜 ⏮️ 🎓 FastAPI
:
from fastapi import APIRouter
router = APIRouter()
@router.get("/users/", tags=["users"])
async def read_users():
return [{"username": "Rick"}, {"username": "Morty"}]
@router.get("/users/me", tags=["users"])
async def read_user_me():
return {"username": "fakecurrentuser"}
@router.get("/users/{username}", tags=["users"])
async def read_user(username: str):
return {"username": username}
➡ 🛠️ ⏮️ APIRouter
¶
& ⤴️ 👆 ⚙️ ⚫️ 📣 👆 ➡ 🛠️.
⚙️ ⚫️ 🎏 🌌 👆 🔜 ⚙️ FastAPI
🎓:
from fastapi import APIRouter
router = APIRouter()
@router.get("/users/", tags=["users"])
async def read_users():
return [{"username": "Rick"}, {"username": "Morty"}]
@router.get("/users/me", tags=["users"])
async def read_user_me():
return {"username": "fakecurrentuser"}
@router.get("/users/{username}", tags=["users"])
async def read_user(username: str):
return {"username": username}
👆 💪 💭 APIRouter
"🐩 FastAPI
" 🎓.
🌐 🎏 🎛 🐕🦺.
🌐 🎏 parameters
, responses
, dependencies
, tags
, ♒️.
Tip
👉 🖼, 🔢 🤙 router
, ✋️ 👆 💪 📛 ⚫️ 👐 👆 💚.
👥 🔜 🔌 👉 APIRouter
👑 FastAPI
📱, ✋️ 🥇, ➡️ ✅ 🔗 & ➕1️⃣ APIRouter
.
🔗¶
👥 👀 👈 👥 🔜 💪 🔗 ⚙️ 📚 🥉 🈸.
👥 🚮 👫 👫 👍 dependencies
🕹 (app/dependencies.py
).
👥 🔜 🔜 ⚙️ 🙅 🔗 ✍ 🛃 X-Token
🎚:
from fastapi import Header, HTTPException
async def get_token_header(x_token: str = Header()):
if x_token != "fake-super-secret-token":
raise HTTPException(status_code=400, detail="X-Token header invalid")
async def get_query_token(token: str):
if token != "jessica":
raise HTTPException(status_code=400, detail="No Jessica token provided")
➕1️⃣ 🕹 ⏮️ APIRouter
¶
➡️ 💬 👆 ✔️ 🔗 💡 🚚 "🏬" ⚪️➡️ 👆 🈸 🕹 app/routers/items.py
.
👆 ✔️ ➡ 🛠️ :
/items/
/items/{item_id}
⚫️ 🌐 🎏 📊 ⏮️ app/routers/users.py
.
✋️ 👥 💚 🙃 & 📉 📟 🍖.
👥 💭 🌐 ➡ 🛠️ 👉 🕹 ✔️ 🎏:
- ➡
prefix
:/items
. tags
: (1️⃣ 🔖:items
).- ➕
responses
. dependencies
: 👫 🌐 💪 👈X-Token
🔗 👥 ✍.
, ↩️ ❎ 🌐 👈 🔠 ➡ 🛠️, 👥 💪 🚮 ⚫️ APIRouter
.
from fastapi import APIRouter, Depends, HTTPException
from ..dependencies import get_token_header
router = APIRouter(
prefix="/items",
tags=["items"],
dependencies=[Depends(get_token_header)],
responses={404: {"description": "Not found"}},
)
fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
@router.get("/")
async def read_items():
return fake_items_db
@router.get("/{item_id}")
async def read_item(item_id: str):
if item_id not in fake_items_db:
raise HTTPException(status_code=404, detail="Item not found")
return {"name": fake_items_db[item_id]["name"], "item_id": item_id}
@router.put(
"/{item_id}",
tags=["custom"],
responses={403: {"description": "Operation forbidden"}},
)
async def update_item(item_id: str):
if item_id != "plumbus":
raise HTTPException(
status_code=403, detail="You can only update the item: plumbus"
)
return {"item_id": item_id, "name": "The great Plumbus"}
➡ 🔠 ➡ 🛠️ ✔️ ▶️ ⏮️ /
, 💖:
@router.get("/{item_id}")
async def read_item(item_id: str):
...
...🔡 🔜 🚫 🔌 🏁 /
.
, 🔡 👉 💼 /items
.
👥 💪 🚮 📇 tags
& ➕ responses
👈 🔜 ✔ 🌐 ➡ 🛠️ 🔌 👉 📻.
& 👥 💪 🚮 📇 dependencies
👈 🔜 🚮 🌐 ➡ 🛠️ 📻 & 🔜 🛠️/❎ 🔠 📨 ⚒ 👫.
Tip
🗒 👈, 🌅 💖 🔗 ➡ 🛠️ 👨🎨, 🙅♂ 💲 🔜 🚶♀️ 👆 ➡ 🛠️ 🔢.
🔚 🏁 👈 🏬 ➡ 🔜:
/items/
/items/{item_id}
...👥 🎯.
- 👫 🔜 ™ ⏮️ 📇 🔖 👈 🔌 👁 🎻
"items"
.- 👫 "🔖" ✴️ ⚠ 🏧 🎓 🧾 ⚙️ (⚙️ 🗄).
- 🌐 👫 🔜 🔌 🔁
responses
. - 🌐 👫 ➡ 🛠️ 🔜 ✔️ 📇
dependencies
🔬/🛠️ ⏭ 👫.- 🚥 👆 📣 🔗 🎯 ➡ 🛠️, 👫 🔜 🛠️ 💁♂️.
- 📻 🔗 🛠️ 🥇, ⤴️
dependencies
👨🎨, & ⤴️ 😐 🔢 🔗. - 👆 💪 🚮
Security
🔗 ⏮️scopes
.
Tip
✔️ dependencies
APIRouter
💪 ⚙️, 🖼, 🚚 🤝 🎂 👪 ➡ 🛠️. 🚥 🔗 🚫 🚮 📦 🔠 1️⃣ 👫.
Check
prefix
, tags
, responses
, & dependencies
🔢 (📚 🎏 💼) ⚒ ⚪️➡️ FastAPI ℹ 👆 ❎ 📟 ❎.
🗄 🔗¶
👉 📟 👨❤👨 🕹 app.routers.items
, 📁 app/routers/items.py
.
& 👥 💪 🤚 🔗 🔢 ⚪️➡️ 🕹 app.dependencies
, 📁 app/dependencies.py
.
👥 ⚙️ ⚖ 🗄 ⏮️ ..
🔗:
from fastapi import APIRouter, Depends, HTTPException
from ..dependencies import get_token_header
router = APIRouter(
prefix="/items",
tags=["items"],
dependencies=[Depends(get_token_header)],
responses={404: {"description": "Not found"}},
)
fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
@router.get("/")
async def read_items():
return fake_items_db
@router.get("/{item_id}")
async def read_item(item_id: str):
if item_id not in fake_items_db:
raise HTTPException(status_code=404, detail="Item not found")
return {"name": fake_items_db[item_id]["name"], "item_id": item_id}
@router.put(
"/{item_id}",
tags=["custom"],
responses={403: {"description": "Operation forbidden"}},
)
async def update_item(item_id: str):
if item_id != "plumbus":
raise HTTPException(
status_code=403, detail="You can only update the item: plumbus"
)
return {"item_id": item_id, "name": "The great Plumbus"}
❔ ⚖ 🗄 👷¶
Tip
🚥 👆 💭 👌 ❔ 🗄 👷, 😣 ⏭ 📄 🔛.
👁 ❣ .
, 💖:
from .dependencies import get_token_header
🔜 ⛓:
- ▶️ 🎏 📦 👈 👉 🕹 (📁
app/routers/items.py
) 🖖 (📁app/routers/
)... - 🔎 🕹
dependencies
(👽 📁app/routers/dependencies.py
)... - & ⚪️➡️ ⚫️, 🗄 🔢
get_token_header
.
✋️ 👈 📁 🚫 🔀, 👆 🔗 📁 app/dependencies.py
.
💭 ❔ 👆 📱/📁 📊 👀 💖:
2️⃣ ❣ ..
, 💖:
from ..dependencies import get_token_header
⛓:
- ▶️ 🎏 📦 👈 👉 🕹 (📁
app/routers/items.py
) 🖖 (📁app/routers/
)... - 🚶 👪 📦 (📁
app/
)... - & 📤, 🔎 🕹
dependencies
(📁app/dependencies.py
)... - & ⚪️➡️ ⚫️, 🗄 🔢
get_token_header
.
👈 👷 ☑ ❗ 👶
🎏 🌌, 🚥 👥 ✔️ ⚙️ 3️⃣ ❣ ...
, 💖:
from ...dependencies import get_token_header
that 🔜 ⛓:
- ▶️ 🎏 📦 👈 👉 🕹 (📁
app/routers/items.py
) 🖖 (📁app/routers/
)... - 🚶 👪 📦 (📁
app/
)... - ⤴️ 🚶 👪 👈 📦 (📤 🙅♂ 👪 📦,
app
🔝 🎚 👶)... - & 📤, 🔎 🕹
dependencies
(📁app/dependencies.py
)... - & ⚪️➡️ ⚫️, 🗄 🔢
get_token_header
.
👈 🔜 🔗 📦 🔛 app/
, ⏮️ 🚮 👍 📁 __init__.py
, ♒️. ✋️ 👥 🚫 ✔️ 👈. , 👈 🔜 🚮 ❌ 👆 🖼. 👶
✋️ 🔜 👆 💭 ❔ ⚫️ 👷, 👆 💪 ⚙️ ⚖ 🗄 👆 👍 📱 🙅♂ 🤔 ❔ 🏗 👫. 👶
🚮 🛃 tags
, responses
, & dependencies
¶
👥 🚫 ❎ 🔡 /items
🚫 tags=["items"]
🔠 ➡ 🛠️ ↩️ 👥 🚮 👫 APIRouter
.
✋️ 👥 💪 🚮 🌅 tags
👈 🔜 ✔ 🎯 ➡ 🛠️, & ➕ responses
🎯 👈 ➡ 🛠️:
from fastapi import APIRouter, Depends, HTTPException
from ..dependencies import get_token_header
router = APIRouter(
prefix="/items",
tags=["items"],
dependencies=[Depends(get_token_header)],
responses={404: {"description": "Not found"}},
)
fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
@router.get("/")
async def read_items():
return fake_items_db
@router.get("/{item_id}")
async def read_item(item_id: str):
if item_id not in fake_items_db:
raise HTTPException(status_code=404, detail="Item not found")
return {"name": fake_items_db[item_id]["name"], "item_id": item_id}
@router.put(
"/{item_id}",
tags=["custom"],
responses={403: {"description": "Operation forbidden"}},
)
async def update_item(item_id: str):
if item_id != "plumbus":
raise HTTPException(
status_code=403, detail="You can only update the item: plumbus"
)
return {"item_id": item_id, "name": "The great Plumbus"}
Tip
👉 🏁 ➡ 🛠️ 🔜 ✔️ 🌀 🔖: ["items", "custom"]
.
& ⚫️ 🔜 ✔️ 👯♂️ 📨 🧾, 1️⃣ 404
& 1️⃣ 403
.
👑 FastAPI
¶
🔜, ➡️ 👀 🕹 app/main.py
.
📥 🌐❔ 👆 🗄 & ⚙️ 🎓 FastAPI
.
👉 🔜 👑 📁 👆 🈸 👈 👔 🌐 👯♂️.
& 🏆 👆 ⚛ 🔜 🔜 🖖 🚮 👍 🎯 🕹, 👑 📁 🔜 🙅.
🗄 FastAPI
¶
👆 🗄 & ✍ FastAPI
🎓 🛎.
& 👥 💪 📣 🌐 🔗 👈 🔜 🌀 ⏮️ 🔗 🔠 APIRouter
:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
🗄 APIRouter
¶
🔜 👥 🗄 🎏 🔁 👈 ✔️ APIRouter
Ⓜ:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
📁 app/routers/users.py
& app/routers/items.py
🔁 👈 🍕 🎏 🐍 📦 app
, 👥 💪 ⚙️ 👁 ❣ .
🗄 👫 ⚙️ "⚖ 🗄".
❔ 🏭 👷¶
📄:
from .routers import items, users
⛓:
- ▶️ 🎏 📦 👈 👉 🕹 (📁
app/main.py
) 🖖 (📁app/
)... - 👀 📦
routers
(📁app/routers/
)... - & ⚪️➡️ ⚫️, 🗄 🔁
items
(📁app/routers/items.py
) &users
(📁app/routers/users.py
)...
🕹 items
🔜 ✔️ 🔢 router
(items.router
). 👉 🎏 1️⃣ 👥 ✍ 📁 app/routers/items.py
, ⚫️ APIRouter
🎚.
& ⤴️ 👥 🎏 🕹 users
.
👥 💪 🗄 👫 💖:
from app.routers import items, users
Info
🥇 ⏬ "⚖ 🗄":
from .routers import items, users
🥈 ⏬ "🎆 🗄":
from app.routers import items, users
💡 🌅 🔃 🐍 📦 & 🕹, ✍ 🛂 🐍 🧾 🔃 🕹.
❎ 📛 💥¶
👥 🏭 🔁 items
🔗, ↩️ 🏭 🚮 🔢 router
.
👉 ↩️ 👥 ✔️ ➕1️⃣ 🔢 📛 router
🔁 users
.
🚥 👥 ✔️ 🗄 1️⃣ ⏮️ 🎏, 💖:
from .routers.items import router
from .routers.users import router
router
⚪️➡️ users
🔜 📁 1️⃣ ⚪️➡️ items
& 👥 🚫🔜 💪 ⚙️ 👫 🎏 🕰.
, 💪 ⚙️ 👯♂️ 👫 🎏 📁, 👥 🗄 🔁 🔗:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
🔌 APIRouter
Ⓜ users
& items
¶
🔜, ➡️ 🔌 router
Ⓜ ⚪️➡️ 🔁 users
& items
:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
Info
users.router
🔌 APIRouter
🔘 📁 app/routers/users.py
.
& items.router
🔌 APIRouter
🔘 📁 app/routers/items.py
.
⏮️ app.include_router()
👥 💪 🚮 🔠 APIRouter
👑 FastAPI
🈸.
⚫️ 🔜 🔌 🌐 🛣 ⚪️➡️ 👈 📻 🍕 ⚫️.
📡 ℹ
⚫️ 🔜 🤙 🔘 ✍ ➡ 🛠️ 🔠 ➡ 🛠️ 👈 📣 APIRouter
.
, ⛅ 🎑, ⚫️ 🔜 🤙 👷 🚥 🌐 🎏 👁 📱.
Check
👆 🚫 ✔️ 😟 🔃 🎭 🕐❔ ✅ 📻.
👉 🔜 ✊ ⏲ & 🔜 🕴 🔨 🕴.
⚫️ 🏆 🚫 📉 🎭. 👶
🔌 APIRouter
⏮️ 🛃 prefix
, tags
, responses
, & dependencies
¶
🔜, ➡️ 🌈 👆 🏢 🤝 👆 app/internal/admin.py
📁.
⚫️ 🔌 APIRouter
⏮️ 📡 ➡ 🛠️ 👈 👆 🏢 💰 🖖 📚 🏗.
👉 🖼 ⚫️ 🔜 💎 🙅. ✋️ ➡️ 💬 👈 ↩️ ⚫️ 💰 ⏮️ 🎏 🏗 🏢, 👥 🚫🔜 🔀 ⚫️ & 🚮 prefix
, dependencies
, tags
, ♒️. 🔗 APIRouter
:
from fastapi import APIRouter
router = APIRouter()
@router.post("/")
async def update_admin():
return {"message": "Admin getting schwifty"}
✋️ 👥 💚 ⚒ 🛃 prefix
🕐❔ ✅ APIRouter
👈 🌐 🚮 ➡ 🛠️ ▶️ ⏮️ /admin
, 👥 💚 🔐 ⚫️ ⏮️ dependencies
👥 ⏪ ✔️ 👉 🏗, & 👥 💚 🔌 tags
& responses
.
👥 💪 📣 🌐 👈 🍵 ✔️ 🔀 ⏮️ APIRouter
🚶♀️ 👈 🔢 app.include_router()
:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
👈 🌌, ⏮️ APIRouter
🔜 🚧 ⚗, 👥 💪 💰 👈 🎏 app/internal/admin.py
📁 ⏮️ 🎏 🏗 🏢.
🏁 👈 👆 📱, 🔠 ➡ 🛠️ ⚪️➡️ admin
🕹 🔜 ✔️:
- 🔡
/admin
. - 🔖
admin
. - 🔗
get_token_header
. - 📨
418
. 👶
✋️ 👈 🔜 🕴 📉 👈 APIRouter
👆 📱, 🚫 🙆 🎏 📟 👈 ⚙️ ⚫️.
, 🖼, 🎏 🏗 💪 ⚙️ 🎏 APIRouter
⏮️ 🎏 🤝 👩🔬.
🔌 ➡ 🛠️¶
👥 💪 🚮 ➡ 🛠️ 🔗 FastAPI
📱.
📥 👥 ⚫️... 🎦 👈 👥 💪 🤷:
from fastapi import Depends, FastAPI
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users
app = FastAPI(dependencies=[Depends(get_query_token)])
app.include_router(users.router)
app.include_router(items.router)
app.include_router(
admin.router,
prefix="/admin",
tags=["admin"],
dependencies=[Depends(get_token_header)],
responses={418: {"description": "I'm a teapot"}},
)
@app.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
& ⚫️ 🔜 👷 ☑, 👯♂️ ⏮️ 🌐 🎏 ➡ 🛠️ 🚮 ⏮️ app.include_router()
.
📶 📡 ℹ
🗒: 👉 📶 📡 ℹ 👈 👆 🎲 💪 🚶.
APIRouter
Ⓜ 🚫 "🗻", 👫 🚫 👽 ⚪️➡️ 🎂 🈸.
👉 ↩️ 👥 💚 🔌 👫 ➡ 🛠️ 🗄 🔗 & 👩💻 🔢.
👥 🚫🔜 ❎ 👫 & "🗻" 👫 ➡ 🎂, ➡ 🛠️ "🖖" (🏤-✍), 🚫 🔌 🔗.
✅ 🏧 🛠️ 🩺¶
🔜, 🏃 uvicorn
, ⚙️ 🕹 app.main
& 🔢 app
:
$ uvicorn app.main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
& 📂 🩺 http://127.0.0.1:8000/docs.
👆 🔜 👀 🏧 🛠️ 🩺, ✅ ➡ ⚪️➡️ 🌐 🔁, ⚙️ ☑ ➡ (& 🔡) & ☑ 🔖:
🔌 🎏 📻 💗 🕰 ⏮️ 🎏 prefix
¶
👆 💪 ⚙️ .include_router()
💗 🕰 ⏮️ 🎏 📻 ⚙️ 🎏 🔡.
👉 💪 ⚠, 🖼, 🎦 🎏 🛠️ 🔽 🎏 🔡, ✅ /api/v1
& /api/latest
.
👉 🏧 ⚙️ 👈 👆 5️⃣📆 🚫 🤙 💪, ✋️ ⚫️ 📤 💼 👆.
🔌 APIRouter
➕1️⃣¶
🎏 🌌 👆 💪 🔌 APIRouter
FastAPI
🈸, 👆 💪 🔌 APIRouter
➕1️⃣ APIRouter
⚙️:
router.include_router(other_router)
⚒ 💭 👆 ⚫️ ⏭ 🔌 router
FastAPI
📱, 👈 ➡ 🛠️ ⚪️➡️ other_router
🔌.