From 20f75765e3427936c5f18276503af0a446d10450 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 10:15:36 +0100 Subject: [PATCH] Update code in endpoints/aid.post.py --- endpoints/aid.post.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 endpoints/aid.post.py diff --git a/endpoints/aid.post.py b/endpoints/aid.post.py new file mode 100644 index 0000000..9735487 --- /dev/null +++ b/endpoints/aid.post.py @@ -0,0 +1,36 @@ +```python +from fastapi import APIRouter, HTTPException +import uuid + +games = [] # In-memory storage + +router = APIRouter() + +@router.post("/aid") +async def save_games( + games_list: list +): + """Save list of games to the database""" + if request.method != "POST": + raise HTTPException(status_code=405, detail="Method Not Allowed") + + for game in games_list: + game_id = str(uuid.uuid4()) + games.append({ + "id": game_id, + "game": game + }) + + return { + "method": "POST", + "_verb": "post", + "message": "Games saved successfully", + "games_saved": len(games_list) + } +``` + +``` +# requirements.txt +fastapi +uvicorn +``` \ No newline at end of file