Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
0c4f17accc
commit
4d4150a3bd
40
endpoints/api/v1/endpoint.post.py
Normal file
40
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,40 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
import random
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
# Sample Abuja area districts/cities
|
||||
ABUJA_CITIES = [
|
||||
"Garki", "Wuse", "Maitama", "Asokoro", "Gwarinpa",
|
||||
"Kubwa", "Nyanya", "Karu", "Jabi", "Utako",
|
||||
"Durumi", "Lugbe", "Gwagwalada", "Kuje", "Bwari",
|
||||
"Dutse", "Life Camp", "Mpape", "Mabushi", "Katampe",
|
||||
"Dakibiyu", "Galadimawa", "Lokogoma", "Apo", "Gudu"
|
||||
]
|
||||
|
||||
@router.post("/api/v1/endpoint")
|
||||
async def generate_abuja_cities(
|
||||
count: int = 5
|
||||
):
|
||||
"""Generate random cities in Abuja"""
|
||||
if count <= 0 or count > len(ABUJA_CITIES):
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"Count must be between 1 and {len(ABUJA_CITIES)}"
|
||||
)
|
||||
|
||||
selected_cities = random.sample(ABUJA_CITIES, count)
|
||||
|
||||
return {
|
||||
"message": "Cities generated successfully",
|
||||
"data": {
|
||||
"cities": selected_cities,
|
||||
"count": len(selected_cities)
|
||||
},
|
||||
"metadata": {
|
||||
"total_available_cities": len(ABUJA_CITIES),
|
||||
"region": "Federal Capital Territory",
|
||||
"country": "Nigeria"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user