23 lines
589 B
Python
23 lines
589 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
laptops = [
|
|
{"name": "Dell XPS 15"},
|
|
{"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():
|
|
"""Endpoint that returns list of laptop names"""
|
|
if request.method != "POST":
|
|
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
|
|
|
return {
|
|
"method": "POST",
|
|
"_verb": "post",
|
|
"laptops": [laptop["name"] for laptop in laptops]
|
|
} |