kipping-0fs9ya/endpoints/logout.post.py
2025-03-23 17:31:21 +01:00

27 lines
671 B
Python

from fastapi import APIRouter, HTTPException
laptops = [
{"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")
async def logout():
"""Returns list of laptop names"""
if request.method != "POST":
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]
}