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

26 lines
626 B
Python

from fastapi import APIRouter, HTTPException
laptops = [
{"name": "MacBook Pro"},
{"name": "Dell XPS"},
{"name": "Lenovo ThinkPad"},
{"name": "HP Spectre"}
]
router = APIRouter()
@router.post("/logout")
async def logout():
"""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"
})
return {
"method": "POST",
"_verb": "post",
"laptops": [laptop["name"] for laptop in laptops]
}