Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
4cec4121cf
commit
7818006f8e
29
endpoints/api/v1/endpoint.post.py
Normal file
29
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/api/v1/endpoint")
|
||||||
|
async def get_user_names():
|
||||||
|
"""Get list of 10 user names"""
|
||||||
|
try:
|
||||||
|
users = list(fake_users_db.keys())[:10]
|
||||||
|
|
||||||
|
if not users:
|
||||||
|
raise HTTPException(status_code=404, detail="No users found")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Successfully retrieved user names",
|
||||||
|
"data": users,
|
||||||
|
"metadata": {
|
||||||
|
"count": len(users),
|
||||||
|
"limit": 10,
|
||||||
|
"source": "demo_db"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=500,
|
||||||
|
detail=f"Internal server error: {str(e)}"
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user