diff --git a/src/main.py b/src/main.py index 46af390..d23880d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,20 +1,12 @@ +from fastapi import FastAPI, HTTPException from typing import Annotated -from fastapi import FastAPI, HTTPException - -from src.entities.cards import CARDS +import src.routers.cards as cards app = FastAPI() +app.include_router(cards.router, prefix="/cards") @app.get("/") async def root(): return {"message": "Hello World!"} - - -@app.get("/cards/{card}") -def get_cards(card: str): - for key in CARDS: - if key in card: - return {"cards": CARDS[card]} - raise HTTPException(status_code=404, detail="Cards with this type not found") diff --git a/src/routers/cards.py b/src/routers/cards.py new file mode 100644 index 0000000..67c5c64 --- /dev/null +++ b/src/routers/cards.py @@ -0,0 +1,13 @@ +from fastapi import APIRouter, HTTPException + +from src.entities.cards import CARDS + +router = APIRouter() + + +@router.get("/{card}") +async def get_cards(card: str): + for key in CARDS: + if key == card: + return {"cards": CARDS[card]} + raise HTTPException(status_code=404, detail="Cards with this type not found")