35 lines
825 B
Python
35 lines
825 B
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.database import fake_users_db
|
|
from typing import Dict
|
|
|
|
router = APIRouter()
|
|
|
|
fake_books_db: Dict = {
|
|
"1": {
|
|
"id": "1",
|
|
"title": "Sample Book",
|
|
"author": "John Doe",
|
|
"year": 2023,
|
|
"available": True
|
|
}
|
|
}
|
|
|
|
@router.get("/books/{book_id}")
|
|
async def get_book(book_id: str):
|
|
"""Get book by ID"""
|
|
book = fake_books_db.get(book_id)
|
|
if not book:
|
|
raise HTTPException(status_code=404, detail="Book not found")
|
|
|
|
return {
|
|
"message": "Book found",
|
|
"data": book,
|
|
"metadata": {
|
|
"source": "demo_db",
|
|
"result_count": 1,
|
|
"features": {
|
|
"details_available": True,
|
|
"can_download": False
|
|
}
|
|
}
|
|
} |