fase 8 afgerond
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, HTTPException, Query
|
||||
|
||||
from app.services.file_discovery_service import FileDiscoveryService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/roots")
|
||||
def get_roots():
|
||||
service = FileDiscoveryService()
|
||||
return {"items": service.list_roots()}
|
||||
|
||||
|
||||
@router.get("/discover")
|
||||
def discover_files(
|
||||
root_id: str = Query(..., min_length=1),
|
||||
subpath: str = Query(""),
|
||||
recursive: bool = Query(False),
|
||||
limit: int = Query(200, ge=1, le=1000),
|
||||
):
|
||||
service = FileDiscoveryService()
|
||||
try:
|
||||
return service.discover(
|
||||
root_id=root_id,
|
||||
subpath=subpath,
|
||||
recursive=recursive,
|
||||
limit=limit,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
Reference in New Issue
Block a user