diff --git a/endpoints/footing.post.py b/endpoints/footing.post.py index 575a9cf..ad2ac5c 100644 --- a/endpoints/footing.post.py +++ b/endpoints/footing.post.py @@ -7,7 +7,8 @@ router = APIRouter() @router.post("/footing") async def save_game( - title: str, + name: str, + description: str, genre: str, platform: str ): @@ -18,8 +19,9 @@ async def save_game( game_id = str(uuid.uuid4()) game = { "id": game_id, - "title": title, - "genre": genre, + "name": name, + "description": description, + "genre": genre, "platform": platform } games.append(game) @@ -33,12 +35,15 @@ async def save_game( @router.get("/games") async def get_games(): - """Fetch all saved games from the database""" + """Fetch all saved games""" if request.method != "GET": raise HTTPException(status_code=405, detail="Method Not Allowed") return { - "method": "GET", - "_verb": "get", + "method": "GET", + "_verb": "get", "games": games - } \ No newline at end of file + } +``` + +This code provides an endpoint `/footing` to save a new game to an in-memory list called `games`. It also includes a `GET` endpoint `/games` to fetch all saved games. The `save_game` function checks if the request method is `POST` and raises a `405 Method Not Allowed` error otherwise. It creates a new `game` dictionary with the provided parameters and a unique `game_id`, appends it to the `games` list, and returns a success message with the `game_id`. The `get_games` function checks if the request method is `GET` and returns the list of `games`. \ No newline at end of file