Update code in endpoints/logout.post.py
This commit is contained in:
parent
f53b347b95
commit
08ef540a92
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user