Spaces:
Sleeping
Sleeping
Download app/api/query.py from pardeep-singh/reading-list: direct link, hf CLI and curl.
- Browser
- Download file 864 Bytes
-
https://huggingface.co/spaces/pardeep-singh/reading-list/resolve/main/app/api/query.py
- Command line
-
hf download hf://spaces/pardeep-singh/reading-list/app/api/query.py
-
curl -L -o query.py https://huggingface.co/spaces/pardeep-singh/reading-list/resolve/main/app/api/query.py
864 Bytes
| from fastapi import APIRouter, Depends, HTTPException | |
| from app.models import Book, BookStats, BookStatusUpdate, Status | |
| from app.store import BookStore, get_store | |
| router = APIRouter() | |
| def list_books( | |
| status: Status | None = None, store: BookStore = Depends(get_store) | |
| ) -> list[Book]: | |
| return store.list_books(status) | |
| def update_book_status( | |
| book_id: int, update: BookStatusUpdate, store: BookStore = Depends(get_store) | |
| ) -> Book: | |
| book = store.update_status(book_id, update.status) | |
| if book is None: | |
| raise HTTPException(status_code=404, detail="Book not found") | |
| return book | |
| def stats(store: BookStore = Depends(get_store)) -> BookStats: | |
| return store.counts() | |