From 8bac8cb2d064542bf326b74c5cde07d70091d2f0 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sun, 23 Mar 2025 16:51:18 +0100 Subject: [PATCH] Update code in endpoints/open.post.py --- endpoints/open.post.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/endpoints/open.post.py b/endpoints/open.post.py index 9e8853f..2617571 100644 --- a/endpoints/open.post.py +++ b/endpoints/open.post.py @@ -3,21 +3,21 @@ from fastapi import APIRouter, HTTPException router = APIRouter() towns = [ - "Yaounde", + "Yaoundé", "Douala", - "Bafoussam", "Garoua", - "Maroua", + "Bafoussam", "Bamenda", - "Ngaoundere", - "Bertoua", - "Ebolowa", - "Kribi" + "Nkongsamba", + "Maroua", + "Ngaoundéré", + "Kumba", + "Edéa" ] @router.post("/open") -async def get_cameroon_towns(): - """endpoint that returns list of town in camerouns""" +async def get_towns(): + """Endpoint that returns list of towns in Cameroun""" if request.method != "POST": raise HTTPException(status_code=405, detail="Method Not Allowed") @@ -25,4 +25,7 @@ async def get_cameroon_towns(): "method": "POST", "_verb": "post", "towns": towns - } \ No newline at end of file + } +``` + +This code defines a POST endpoint `/open` that returns a list of towns in Cameroun. It uses an in-memory list `towns` to store the town names. The endpoint checks if the request method is POST, and if not, it raises a 405 Method Not Allowed error. The response includes the method ("POST"), the method metadata ("_verb": "post"), and the list of towns. \ No newline at end of file