diff --git a/endpoints/logout.post.py b/endpoints/logout.post.py index 36f9e68..0d8ffd1 100644 --- a/endpoints/logout.post.py +++ b/endpoints/logout.post.py @@ -1,8 +1,8 @@ from fastapi import APIRouter, HTTPException laptops = [ - {"name": "MacBook Pro"}, {"name": "Dell XPS 13"}, + {"name": "MacBook Pro 16"}, {"name": "Lenovo ThinkPad X1 Carbon"}, {"name": "HP Spectre x360"}, {"name": "Asus ZenBook Pro Duo"} @@ -12,24 +12,12 @@ router = APIRouter() @router.post("/logout") async def logout(): - """Returns list of laptop names""" + """endpoints that returns list of laptops names""" if request.method != "POST": - raise HTTPException(status_code=405, detail={ - "message": "Method Not Allowed", - "method": "POST", - "_verb": "post" - }) + raise HTTPException(status_code=405, detail="Method Not Allowed") return { - "laptops": [laptop["name"] for laptop in laptops], "method": "POST", - "_verb": "post" - } -``` - -This implementation follows the provided rules and examples: - -- It uses the `@router.post` decorator for the `/logout` endpoint. -- It checks if the request method is POST, and raises a 405 Method Not Allowed error if not. -- The response includes a list of laptop names from the `laptops` list. -- The response also includes the `"method": "POST"` and `"_verb": "post"` fields as required. \ No newline at end of file + "_verb": "post", + "laptops": [laptop["name"] for laptop in laptops] + } \ No newline at end of file