hockey-2gxyw1/endpoints/api/v1/endpoint.post.py
2025-03-18 08:29:48 +00:00

32 lines
1013 B
Python

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"
)