Base router and some Gelöt :)
This commit is contained in:
parent
c278bed0b7
commit
ac2ab19a76
3 changed files with 37 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
from fastapi import FastAPI
|
||||
|
||||
from .routers import router
|
||||
from .settings import SETTINGS
|
||||
|
||||
app = FastAPI(
|
||||
|
@ -17,3 +18,5 @@ app = FastAPI(
|
|||
docs_url=SETTINGS.docs_url,
|
||||
redoc_url=SETTINGS.redoc_url,
|
||||
)
|
||||
|
||||
app.include_router(router)
|
||||
|
|
7
api/advent22_api/routers/__init__.py
Normal file
7
api/advent22_api/routers/__init__.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from fastapi import APIRouter
|
||||
|
||||
from . import abspacken
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
|
||||
router.include_router(abspacken.router)
|
27
api/advent22_api/routers/abspacken.py
Normal file
27
api/advent22_api/routers/abspacken.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import asyncio
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(prefix="/abspacken", tags=["abspacken"])
|
||||
|
||||
|
||||
async def get_kurix(kgs: float) -> float:
|
||||
await asyncio.sleep(2)
|
||||
|
||||
return kgs / 1.13
|
||||
|
||||
|
||||
@router.post("/uwe")
|
||||
async def uwe(
|
||||
kgs: float = 10,
|
||||
firma: str = "Vodafone"
|
||||
) -> str:
|
||||
kurix = await get_kurix(kgs)
|
||||
|
||||
return f"UWE hat bei {firma} einen beachtlichen Haufen von " \
|
||||
f"{kgs} Kg ({kurix:.3f} Kurix) auf den Läufer geschissen."
|
||||
|
||||
|
||||
@router.get("/torsten/{ding}")
|
||||
async def torsten(ding: str) -> str:
|
||||
return "Der Alphakevin Torsten hat ein " f"langes {ding}."
|
Loading…
Reference in a new issue