Update code in endpoints/african-countries.get.py

This commit is contained in:
Backend IM Bot 2025-03-20 21:50:55 +00:00
parent ae99797d1f
commit c0916c2349

View File

@ -0,0 +1,34 @@
from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
import random
router = APIRouter()
AFRICAN_COUNTRIES = [
"Algeria", "Angola", "Benin", "Botswana", "Burkina Faso", "Burundi",
"Cameroon", "Cape Verde", "Central African Republic", "Chad", "Comoros",
"Congo", "Democratic Republic of the Congo", "Djibouti", "Egypt",
"Equatorial Guinea", "Eritrea", "Ethiopia", "Gabon", "Gambia", "Ghana",
"Guinea", "Guinea-Bissau", "Ivory Coast", "Kenya", "Lesotho", "Liberia",
"Libya", "Madagascar", "Malawi", "Mali", "Mauritania", "Mauritius",
"Morocco", "Mozambique", "Namibia", "Niger", "Nigeria", "Rwanda",
"Sao Tome and Principe", "Senegal", "Seychelles", "Sierra Leone",
"Somalia", "South Africa", "South Sudan", "Sudan", "Swaziland",
"Tanzania", "Togo", "Tunisia", "Uganda", "Zambia", "Zimbabwe"
]
@router.get("/african-countries")
async def get_random_african_country():
"""Generate a random African country"""
random_country = random.choice(AFRICAN_COUNTRIES)
return {
"message": "Random African country generated successfully",
"data": {
"country": random_country
},
"metadata": {
"total_countries": len(AFRICAN_COUNTRIES),
"source": "static_list"
}
}