lucia-wh0i6w/endpoints/books.get.py
2025-03-28 19:19:04 +00:00

28 lines
667 B
Python

from fastapi import APIRouter, status
from typing import List, Dict
router = APIRouter()
@router.get("/books", status_code=status.HTTP_200_OK, response_model=List[Dict])
async def get_books():
books = [
{
"id": 1,
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": 1925
},
{
"id": 2,
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": 1960
},
{
"id": 3,
"title": "1984",
"author": "George Orwell",
"year": 1949
}
]
return books