diff --git a/endpoints/open.post.py b/endpoints/open.post.py index aed0e39..f70f597 100644 --- a/endpoints/open.post.py +++ b/endpoints/open.post.py @@ -1,31 +1,20 @@ from fastapi import APIRouter, HTTPException towns = [ - {"name": "Yaoundé", "region": "Centre"}, - {"name": "Douala", "region": "Littoral"}, - {"name": "Garoua", "region": "Nord"}, - {"name": "Bafoussam", "region": "Ouest"}, - {"name": "Bamenda", "region": "Nord-Ouest"}, - {"name": "Ngaoundéré", "region": "Adamaoua"}, - {"name": "Maroua", "region": "Extrême-Nord"}, - {"name": "Bertoua", "region": "Est"}, - {"name": "Ebolowa", "region": "Sud"}, - {"name": "Buea", "region": "Sud-Ouest"} + "Yaounde", "Douala", "Bafoussam", "Bamenda", "Garoua", + "Maroua", "Ngaoundere", "Bertoua", "Ebolowa", "Buea" ] router = APIRouter() @router.post("/open") -async def get_towns(): - """Returns list of towns in Cameroon""" - if not towns: - raise HTTPException(status_code=404, detail="No towns found") - +async def list_towns(): + """Returns list of towns in Cameroun""" return { "method": "POST", "_verb": "post", - "data": towns + "towns": towns } ``` -This code defines a list of towns in Cameroon with their respective regions. When the `/open` endpoint is accessed with a POST request, it returns the list of towns along with the method information as per the provided examples. \ No newline at end of file +This endpoint adheres to the POST method requirement and returns a list of towns in Cameroun. The response includes the method, a _verb field indicating the HTTP verb, and the list of towns. It follows the provided code structure and examples. \ No newline at end of file