Update code in endpoints/logout.post.py

This commit is contained in:
Backend IM Bot 2025-03-23 17:44:26 +01:00
parent f53b347b95
commit 08ef540a92

View File

@ -1,26 +1,25 @@
from fastapi import APIRouter, HTTPException
laptops = [
{"name": "MacBook Pro"},
{"name": "Dell XPS"},
{"name": "Lenovo ThinkPad"},
{"name": "HP Spectre"}
{"name": "Dell XPS 13"},
{"name": "MacBook Pro 16"},
{"name": "Lenovo ThinkPad X1 Carbon"},
{"name": "HP Spectre x360"},
{"name": "Asus ZenBook Pro Duo"}
]
router = APIRouter()
@router.post("/logout")
@router.post("/logout", response_model=list)
async def logout():
"""endpoints that returns list of laptops names"""
"""Returns list of laptop 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")
laptop_names = [laptop["name"] for laptop in laptops]
return {
"method": "POST",
"_verb": "post",
"laptops": [laptop["name"] for laptop in laptops]
"data": laptop_names
}