25 lines
895 B
Python
25 lines
895 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
people = [
|
|
{"name": "Alice", "age": 55, "country": "UK"},
|
|
{"name": "Bob", "age": 45, "country": "USA"},
|
|
{"name": "Charlie", "age": 60, "country": "ESP"},
|
|
{"name": "David", "age": 35, "country": "UK"},
|
|
{"name": "Eve", "age": 52, "country": "USA"}
|
|
]
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/human")
|
|
async def get_older_people():
|
|
"""Fetch list of people over 50 years of age"""
|
|
older_people = [p for p in people if p["age"] > 50]
|
|
|
|
return {
|
|
"method": "GET",
|
|
"_verb": "get",
|
|
"data": older_people
|
|
}
|
|
```
|
|
|
|
This endpoint defines a list of people with their name, age, and country. The `get_older_people` function filters this list to only include people whose age is over 50 years old. The response includes the filtered list of older people, along with the method metadata as per the requirements. |