INNER CODE UNIT · Python

get_dataset_image

virajmavani/semi-auto-image-annotation-tool · web/backend/main.py:519

async def get_dataset_image(filename: str):
    """Serve image from dataset directory"""
    image_path = get_safe_image_path(filename)
    return FileResponse(image_path)


@app.get("/api/browse")
async def browse_directory(path: str = "~"):
    """List subdirectories at the given path for the directory browser UI"""
    try:
        dir_path = Path(path).expanduser().resolve()

        if not dir_path.is_relative_to(Path.home()):
            raise HTTPException(status_code=400, detail="Path is outside the allowed directory")

        if not dir_path.exists() or not dir_path.is_dir():
            raise HTTPException(status_code=400, detail="Invalid directory path")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…