fender-wmtucy/endpoints/api/v1/endpoint.get.py
2025-03-18 09:38:59 +00:00

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
}
}
}