Add basic backend infrastructure

Signed-off-by: Felipe Cardoso <felipe.cardoso@hotmail.it>
This commit is contained in:
2025-01-22 18:02:07 +01:00
parent 80c8537614
commit 805ed647cd
16 changed files with 179 additions and 0 deletions

View 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))