item.py 460 B

12345678910111213141516171819202122
  1. from fastapi import APIRouter, Depends
  2. from sqlalchemy.orm import Session
  3. from app.api.dependencies.db import get_db
  4. from app.crud.crud_item import get_items
  5. from app.schemas.item import Item
  6. router = APIRouter()
  7. @router.get("/", response_model=list[Item])
  8. def read_items(
  9. skip: int = 0,
  10. limit: int = 100,
  11. db: Session = Depends(get_db),
  12. ):
  13. """
  14. Retrieve items.
  15. """
  16. items = get_items(db, skip=skip, limit=limit)
  17. return items