pprojject-q1q8rm/endpoints/countries.get.py
2025-03-23 08:31:06 +01:00

34 lines
713 B
Python

from fastapi import APIRouter, Request
router = APIRouter()
west_african_countries = [
"Benin",
"Burkina Faso",
"Cape Verde",
"Gambia",
"Ghana",
"Guinea",
"Guinea-Bissau",
"Ivory Coast",
"Liberia",
"Mali",
"Mauritania",
"Niger",
"Nigeria",
"Senegal",
"Sierra Leone",
"Togo"
]
@router.get("/countries")
async def get_west_african_countries(request: Request):
"""endpoint that returns list of countries in west africa"""
if request.method != "GET":
raise HTTPException(status_code=405, detail="Method Not Allowed")
return {
"method": "GET",
"_verb": "get",
"countries": west_african_countries
}