from fastapi import APIRouter, HTTPException import uuid games = [] # In-memory storage router = APIRouter() @router.post("/game") async def save_game( game_name: str, developer: str, genre: str, price: float ): """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()) game = { "id": game_id, "name": game_name, "developer": developer, "genre": genre, "price": price } games.append(game) return { "message": "Game saved successfully", "game_id": game_id, "method": "POST", "_verb": "post" } @router.get("/games") async def get_games(): """Fetch all games from the database""" if request.method != "GET": raise HTTPException(status_code=405, detail="Method Not Allowed") return { "games": games, "method": "GET", "_verb": "get" }