From de01788aa50a32c0a0e304b1e9e1e6cfbf282c49 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 18 Mar 2025 08:29:48 +0000 Subject: [PATCH] Update code in endpoints/api/v1/endpoint.post.py --- endpoints/api/v1/endpoint.post.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 endpoints/api/v1/endpoint.post.py diff --git a/endpoints/api/v1/endpoint.post.py b/endpoints/api/v1/endpoint.post.py new file mode 100644 index 0000000..144a11c --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -0,0 +1,32 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db + +router = APIRouter() + +# Demo sports database +fake_sports_db = { + "1": {"id": "1", "name": "Football", "type": "Team Sport"}, + "2": {"id": "2", "name": "Basketball", "type": "Team Sport"}, + "3": {"id": "3", "name": "Tennis", "type": "Individual Sport"}, + "4": {"id": "4", "name": "Swimming", "type": "Individual Sport"} +} + +@router.post("/api/v1/endpoint") +async def get_sports_list(): + """Get list of all sports""" + try: + sports_list = list(fake_sports_db.values()) + + return { + "message": "Sports list retrieved successfully", + "data": sports_list, + "metadata": { + "total_count": len(sports_list), + "categories": ["Team Sport", "Individual Sport"] + } + } + except Exception as e: + raise HTTPException( + status_code=500, + detail="Error retrieving sports list" + ) \ No newline at end of file