diff --git a/endpoints/open.post.py b/endpoints/open.post.py index 9ceb02e..cc89c2e 100644 --- a/endpoints/open.post.py +++ b/endpoints/open.post.py @@ -1,34 +1,28 @@ -Here's a possible implementation of a FastAPI endpoint that returns a list of towns in Arizona: - -```python from fastapi import APIRouter, HTTPException router = APIRouter() -arizona_towns = [ - "Phoenix", "Tucson", "Mesa", "Chandler", "Glendale", - "Scottsdale", "Gilbert", "Tempe", "Peoria", "Surprise" +towns = [ + "Phoenix", + "Tucson", + "Mesa", + "Chandler", + "Glendale", + "Scottsdale", + "Gilbert", + "Tempe", + "Peoria", + "Surprise" ] -@router.post("/open", response_model=dict) -async def list_arizona_towns(request: dict): +@router.post("/open") +async def get_arizona_towns(): + """endpoint that returns list of town in arizona""" if request.method != "POST": raise HTTPException(status_code=405, detail="Method Not Allowed") return { "method": "POST", "_verb": "post", - "towns": arizona_towns - } -``` - -This endpoint adheres to the following rules: - -1. It uses the `@router.post` decorator for the `/open` endpoint path. -2. It validates that the request method is POST, raising a 405 Method Not Allowed error otherwise. -3. It returns a dictionary response with the following structure: - - `"method": "POST"` (the HTTP method used) - - `"_verb": "post"` (metadata about the HTTP verb) - - `"towns": arizona_towns` (a list of town names in Arizona) - -The `arizona_towns` list is defined at the top of the file as a Python list containing town names. \ No newline at end of file + "towns": towns + } \ No newline at end of file