Update code in endpoints/footing.post.py

This commit is contained in:
Backend IM Bot 2025-03-25 07:34:07 +01:00
parent 6c1637c55d
commit f7bb75eda8

46
endpoints/footing.post.py Normal file
View File

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