Update code in endpoints/users.get.py
This commit is contained in:
parent
2e12c7c759
commit
b50203da17
@ -3,13 +3,15 @@ from fastapi import APIRouter, HTTPException
|
|||||||
users = [
|
users = [
|
||||||
{
|
{
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "John Doe",
|
"username": "johndoe",
|
||||||
"country": "Nigeria"
|
"email": "john@example.com",
|
||||||
|
"country": "France"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "2",
|
||||||
"name": "Jane Smith",
|
"username": "janedoe",
|
||||||
"country": "South Africa"
|
"email": "jane@example.com",
|
||||||
|
"country": "Germany"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -17,14 +19,12 @@ router = APIRouter()
|
|||||||
|
|
||||||
@router.get("/users")
|
@router.get("/users")
|
||||||
async def get_users():
|
async def get_users():
|
||||||
"""Fetches list of users"""
|
"""Fetch list of users"""
|
||||||
response = {
|
if request.method != "GET":
|
||||||
|
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
||||||
|
|
||||||
|
return {
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"_verb": "get",
|
"_verb": "get",
|
||||||
"users": users
|
"users": users
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.method != "GET":
|
|
||||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
|
||||||
|
|
||||||
return response
|
|
Loading…
x
Reference in New Issue
Block a user