diff --git a/endpoints/users.get.py b/endpoints/users.get.py new file mode 100644 index 0000000..c4789d3 --- /dev/null +++ b/endpoints/users.get.py @@ -0,0 +1,36 @@ +from fastapi import APIRouter, HTTPException + +users = [ + { + "id": "1", + "name": "John Doe", + "email": "john@example.com" + }, + { + "id": "2", + "name": "Jane Smith", + "email": "jane@example.com" + } +] + +router = APIRouter() + +@router.get("/users") +async def get_users(): + """Fetch list of users""" + return { + "method": "GET", + "_verb": "get", + "users": 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 + +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