35 lines
933 B
Python
35 lines
933 B
Python
from typing import List
|
|
|
|
from fastapi import APIRouter, HTTPException, Query
|
|
|
|
from app.models.sample import Sample
|
|
from app.services.sample_manager import SampleManager
|
|
|
|
router = APIRouter()
|
|
sample_manager = SampleManager()
|
|
|
|
|
|
@router.get("/list", response_model=List[Sample])
|
|
async def list_samples(
|
|
limit: int = Query(20, ge=1, le=100),
|
|
offset: int = Query(0, ge=0)
|
|
):
|
|
"""
|
|
List sample images with pagination
|
|
"""
|
|
try:
|
|
return await sample_manager.list_samples(limit, offset)
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
@router.get("/latest", response_model=List[Sample])
|
|
async def get_latest_samples(count: int = Query(5, ge=1, le=20)):
|
|
"""
|
|
Get the most recent sample images
|
|
"""
|
|
try:
|
|
return await sample_manager.get_latest_samples(count)
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|