Add basic backend infrastructure
Signed-off-by: Felipe Cardoso <felipe.cardoso@hotmail.it>
This commit is contained in:
34
backend/app/api/routes/samples.py
Normal file
34
backend/app/api/routes/samples.py
Normal file
@@ -0,0 +1,34 @@
|
||||
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))
|
||||
Reference in New Issue
Block a user