26 lines
626 B
Python
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]
|
|
} |