diff --git a/endpoints/man.get.py b/endpoints/man.get.py new file mode 100644 index 0000000..3c8ff5f --- /dev/null +++ b/endpoints/man.get.py @@ -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. \ No newline at end of file