From 0164546aaded043e4a472206ac9727c478d25794 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sun, 23 Mar 2025 17:34:23 +0100 Subject: [PATCH] Update code in endpoints/logout.post.py --- endpoints/logout.post.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/endpoints/logout.post.py b/endpoints/logout.post.py index fd45118..36f9e68 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"} @@ -21,7 +21,15 @@ async def logout(): }) return { + "laptops": [laptop["name"] for laptop in laptops], "method": "POST", - "_verb": "post", - "laptops": [laptop["name"] for laptop in laptops] - } \ No newline at end of file + "_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