Update code in endpoints/footing.post.py
This commit is contained in:
parent
676b27b9e2
commit
67c4d2624d
@ -8,22 +8,23 @@ router = APIRouter()
|
|||||||
|
|
||||||
@router.post("/footing")
|
@router.post("/footing")
|
||||||
async def save_game(
|
async def save_game(
|
||||||
name: str,
|
title: str,
|
||||||
description: str,
|
description: str,
|
||||||
category: str
|
genre: str,
|
||||||
|
platform: str
|
||||||
):
|
):
|
||||||
"""Save a new game to the database"""
|
"""Save a new game to the database"""
|
||||||
if request.method != "POST":
|
if request.method != "POST":
|
||||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
||||||
|
|
||||||
game_id = str(uuid.uuid4())
|
game_id = str(uuid.uuid4())
|
||||||
game = {
|
games.append({
|
||||||
"id": game_id,
|
"id": game_id,
|
||||||
"name": name,
|
"title": title,
|
||||||
"description": description,
|
"description": description,
|
||||||
"category": category
|
"genre": genre,
|
||||||
}
|
"platform": platform
|
||||||
games.append(game)
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
@ -34,13 +35,13 @@ async def save_game(
|
|||||||
|
|
||||||
@router.get("/games")
|
@router.get("/games")
|
||||||
async def get_games():
|
async def get_games():
|
||||||
"""Fetch all games from the database"""
|
"""Fetch all saved games from the database"""
|
||||||
if request.method != "GET":
|
if request.method != "GET":
|
||||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"_verb": "get",
|
"_verb": "get",
|
||||||
"games": games
|
"games": games
|
||||||
}
|
}
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user