30 lines
577 B
Python
30 lines
577 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
users = [
|
|
{
|
|
"id": "1",
|
|
"name": "John Doe",
|
|
"country": "Nigeria"
|
|
},
|
|
{
|
|
"id": "2",
|
|
"name": "Jane Smith",
|
|
"country": "South Africa"
|
|
}
|
|
]
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/users")
|
|
async def get_users():
|
|
"""Fetches list of users"""
|
|
response = {
|
|
"method": "GET",
|
|
"_verb": "get",
|
|
"users": users
|
|
}
|
|
|
|
if request.method != "GET":
|
|
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
|
|
|
return response |