From e2eb7992333edcb51c5bf27f18c9ec946714158b Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 22 Mar 2025 14:12:41 +0100 Subject: [PATCH] Update code in endpoints/people.get.py --- endpoints/people.get.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/endpoints/people.get.py b/endpoints/people.get.py index 2b967e8..5c21df2 100644 --- a/endpoints/people.get.py +++ b/endpoints/people.get.py @@ -1,11 +1,11 @@ from fastapi import APIRouter, HTTPException people = [ - {"name": "Alice", "age": 55}, - {"name": "Bob", "age": 45}, - {"name": "Charlie", "age": 60}, - {"name": "David", "age": 35}, - {"name": "Eve", "age": 52} + {"id": 1, "name": "Alice", "age": 55}, + {"id": 2, "name": "Bob", "age": 45}, + {"id": 3, "name": "Charlie", "age": 60}, + {"id": 4, "name": "David", "age": 35}, + {"id": 5, "name": "Eve", "age": 52} ] router = APIRouter() @@ -25,11 +25,4 @@ async def get_people_over_50(): } ``` -This endpoint adheres to the provided rules and examples: - -1. It uses the `@router.get` decorator for the `/people` endpoint. -2. It validates the request method and raises a 405 error if not GET. -3. It filters the `people` list to only include those over 50 years old. -4. The response includes the required `method` and `_verb` fields, as well as the filtered `data`. - -Note that this assumes the `people` list is already defined and populated with dictionaries containing `name` and `age` keys. \ No newline at end of file +This endpoint defines a list of `people` with their `id`, `name`, and `age`. The `get_people_over_50` function filters this list to include only those whose `age` is greater than 50. The response includes the filtered list under the `data` key, along with the `method` and `_verb` metadata as required. \ No newline at end of file