Update code in endpoints/logout.post.py
This commit is contained in:
parent
14e3690562
commit
0164546aad
@ -1,8 +1,8 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
||||||
laptops = [
|
laptops = [
|
||||||
|
{"name": "MacBook Pro"},
|
||||||
{"name": "Dell XPS 13"},
|
{"name": "Dell XPS 13"},
|
||||||
{"name": "MacBook Pro 16\""},
|
|
||||||
{"name": "Lenovo ThinkPad X1 Carbon"},
|
{"name": "Lenovo ThinkPad X1 Carbon"},
|
||||||
{"name": "HP Spectre x360"},
|
{"name": "HP Spectre x360"},
|
||||||
{"name": "Asus ZenBook Pro Duo"}
|
{"name": "Asus ZenBook Pro Duo"}
|
||||||
@ -21,7 +21,15 @@ async def logout():
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"laptops": [laptop["name"] for laptop in laptops],
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"_verb": "post",
|
"_verb": "post"
|
||||||
"laptops": [laptop["name"] for laptop in laptops]
|
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This implementation follows the provided rules and examples:
|
||||||
|
|
||||||
|
- It uses the `@router.post` decorator for the `/logout` endpoint.
|
||||||
|
- It checks if the request method is POST, and raises a 405 Method Not Allowed error if not.
|
||||||
|
- The response includes a list of laptop names from the `laptops` list.
|
||||||
|
- The response also includes the `"method": "POST"` and `"_verb": "post"` fields as required.
|
Loading…
x
Reference in New Issue
Block a user