From 7818006f8e89a9882a4921c748f60f70883debe3 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 18 Mar 2025 09:32:53 +0000 Subject: [PATCH] Update code in endpoints/api/v1/endpoint.post.py --- endpoints/api/v1/endpoint.post.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 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..d25ccc2 --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -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)}" + ) \ No newline at end of file