Update code in endpoints/users.get.py
This commit is contained in:
parent
ca1dd01706
commit
56aa633c85
@ -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`.
|
||||
The code follows the provided rules and examples, returning only the list of users for a `GET` request to `/users`.
|
Loading…
x
Reference in New Issue
Block a user