Update code in endpoints/books.get.py
This commit is contained in:
parent
a4632495d9
commit
8464c22584
@ -3,20 +3,22 @@ from core.database import fake_users_db
|
|||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
fake_books_db = {
|
|
||||||
"1": {"id": "1", "title": "The Great Gatsby", "author": "F. Scott Fitzgerald"},
|
|
||||||
"2": {"id": "2", "title": "1984", "author": "George Orwell"},
|
|
||||||
"3": {"id": "3", "title": "To Kill a Mockingbird", "author": "Harper Lee"}
|
|
||||||
}
|
|
||||||
|
|
||||||
@router.get("/books")
|
@router.get("/books")
|
||||||
async def get_books():
|
async def get_books():
|
||||||
"""Get all books from the database"""
|
"""Get list of demo books"""
|
||||||
|
books = [
|
||||||
|
{"id": 1, "title": "The Great Gatsby", "author": "F. Scott Fitzgerald"},
|
||||||
|
{"id": 2, "title": "To Kill a Mockingbird", "author": "Harper Lee"},
|
||||||
|
{"id": 3, "title": "1984", "author": "George Orwell"},
|
||||||
|
{"id": 4, "title": "Pride and Prejudice", "author": "Jane Austen"},
|
||||||
|
{"id": 5, "title": "The Catcher in the Rye", "author": "J.D. Salinger"}
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Books retrieved successfully",
|
"message": "Books retrieved successfully",
|
||||||
"data": list(fake_books_db.values()),
|
"data": books,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"total_count": len(fake_books_db),
|
"total_count": len(books),
|
||||||
"source": "demo_db"
|
"source": "demo_db"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user