Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
3167c7154b
commit
de01788aa5
32
endpoints/api/v1/endpoint.post.py
Normal file
32
endpoints/api/v1/endpoint.post.py
Normal file
@ -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"
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user