from fastapi import APIRouter, HTTPException import uuid games = [] # In-memory storage router = APIRouter() @router.post("/sports") async def save_game( name: str, description: str, category: str ): """Save a new game to the database""" if request.method != "POST": raise HTTPException(status_code=405, detail="Method Not Allowed") game_id = str(uuid.uuid4()) new_game = { "id": game_id, "name": name, "description": description, "category": category } games.append(new_game) return { "method": "POST", "_verb": "post", "message": "Game saved successfully", "game_id": game_id } @router.get("/sports") async def get_games(): """Fetch all games from the database""" if request.method != "GET": raise HTTPException(status_code=405, detail="Method Not Allowed") return { "method": "GET", "_verb": "get", "games": games }