diff --git a/endpoints/footin.post.py b/endpoints/footin.post.py new file mode 100644 index 0000000..c860511 --- /dev/null +++ b/endpoints/footin.post.py @@ -0,0 +1,36 @@ +from fastapi import APIRouter, HTTPException +from pydantic import BaseModel +from typing import List + +games = [] # In-memory storage + +router = APIRouter() + +@router.post("/footin") +async def save_game(game: GameSchema): + """Save a new game to the database""" + if request.method != "POST": + raise HTTPException(status_code=405, detail="Method Not Allowed") + + game_dict = game.dict() + game_dict["id"] = len(games) + 1 + games.append(game_dict) + + return { + "method": "POST", + "_verb": "post", + "message": "Game saved successfully", + "game": game_dict + } + +@router.post("/footin") +async def get_games(): + """Fetch all games from the database""" + if request.method != "POST": + raise HTTPException(status_code=405, detail="Method Not Allowed") + + return { + "method": "POST", + "_verb": "post", + "games": [game for game in games] + } \ No newline at end of file