Update code in endpoints/countries.get.py
This commit is contained in:
parent
7ee9f97a3b
commit
7f87250986
34
endpoints/countries.get.py
Normal file
34
endpoints/countries.get.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user