From 6c1637c55d253e7e7950fa5960011cceb42c2d26 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 06:59:10 +0100 Subject: [PATCH] Update code in endpoints/footin.post.py --- endpoints/footin.post.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 endpoints/footin.post.py 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