diff --git a/endpoints/logout.post.py b/endpoints/logout.post.py index b37e44f..898276c 100644 --- a/endpoints/logout.post.py +++ b/endpoints/logout.post.py @@ -1,23 +1,36 @@ from fastapi import APIRouter, HTTPException laptops = [ - {"name": "Dell XPS 15"}, - {"name": "MacBook Pro 16"}, - {"name": "Lenovo ThinkPad X1 Carbon"}, - {"name": "HP Spectre x360"}, - {"name": "Asus ZenBook Pro Duo"} + {"name": "MacBook Pro"}, + {"name": "Dell XPS"}, + {"name": "Lenovo ThinkPad"}, + {"name": "HP Spectre"} ] router = APIRouter() @router.post("/logout") async def logout(): - """Endpoint that returns list of laptop names""" + """Returns list of laptop names""" if request.method != "POST": - raise HTTPException(status_code=405, detail="Method Not Allowed") + raise HTTPException(status_code=405, detail={ + "message": "Method Not Allowed", + "method": "POST", + "_verb": "post" + }) return { "method": "POST", - "_verb": "post", "laptops": [laptop["name"] for laptop in laptops] - } \ No newline at end of file + } +``` + +This implementation follows the provided rules and examples: + +1. It uses the `@router.post` decorator for the `/logout` endpoint. +2. It checks if the request method is POST, and raises a 405 Method Not Allowed error if not. +3. The response includes the "method": "POST" field. +4. It returns a list of laptop names from the in-memory `laptops` list. +5. The response structure matches the provided examples. + +Note that this endpoint does not actually handle any logout functionality, as the description provided was "endpoints that returns list of laptops names". \ No newline at end of file