From 56aa633c85cb547cc1b68a8bea7f2efa9cbbbb1f Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 22 Mar 2025 13:37:35 +0100 Subject: [PATCH] Update code in endpoints/users.get.py --- endpoints/users.get.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/endpoints/users.get.py b/endpoints/users.get.py index c4789d3..9ffb5f0 100644 --- a/endpoints/users.get.py +++ b/endpoints/users.get.py @@ -1,16 +1,9 @@ from fastapi import APIRouter, HTTPException users = [ - { - "id": "1", - "name": "John Doe", - "email": "john@example.com" - }, - { - "id": "2", - "name": "Jane Smith", - "email": "jane@example.com" - } + {"id": "1", "name": "Alice"}, + {"id": "2", "name": "Bob"}, + {"id": "3", "name": "Charlie"} ] router = APIRouter() @@ -28,9 +21,11 @@ async def get_users(): To summarize: - Imported necessary modules -- Initialized an in-memory `users` list with example data -- Created a `/users` endpoint using `@router.get` decorator -- Returned a dict with `method`, `_verb` metadata and the `users` list -- Followed the provided code structure and examples strictly +- Initialized an in-memory `users` list with sample data +- Created a `GET` endpoint at `/users` path using `@router.get` decorator +- Returned a dictionary response with: + - `"method": "GET"` to include the HTTP method + - `"_verb": "get"` for method metadata + - `"users": users` to return the list of user dictionaries -This endpoint will return the list of users with their names and emails when accessed via a GET request to `/users`. \ No newline at end of file +The code follows the provided rules and examples, returning only the list of users for a `GET` request to `/users`. \ No newline at end of file