Update code in endpoints/man.get.py
This commit is contained in:
parent
2392849416
commit
daa708c269
25
endpoints/man.get.py
Normal file
25
endpoints/man.get.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
||||||
|
people = [
|
||||||
|
{"name": "Alice", "age": 55, "country": "UK"},
|
||||||
|
{"name": "Bob", "age": 45, "country": "ESP"},
|
||||||
|
{"name": "Charlie", "age": 60, "country": "Nigeria"},
|
||||||
|
{"name": "David", "age": 52, "country": "UK"},
|
||||||
|
{"name": "Eve", "age": 48, "country": "ESP"}
|
||||||
|
]
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.get("/man")
|
||||||
|
async def get_people_over_50():
|
||||||
|
"""Fetches list of people over 50 years of age"""
|
||||||
|
over_50 = [p for p in people if p["age"] > 50]
|
||||||
|
|
||||||
|
return {
|
||||||
|
"method": "GET",
|
||||||
|
"_verb": "get",
|
||||||
|
"data": over_50
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This endpoint defines a list of people with their name, age, and country. The `get_people_over_50` function filters the list to only include people whose age is greater than 50, and returns a dictionary with the method metadata and the filtered list of people.
|
Loading…
x
Reference in New Issue
Block a user