2026-05-18-19-06-50 构建网页端分割工作台

This commit is contained in:
2026-05-18 19:11:58 +08:00
parent dd2a49ad91
commit 77b8ecdfbe
10 changed files with 851 additions and 175 deletions

View File

@@ -52,6 +52,24 @@ def methods() -> dict[str, Any]:
return {"methods": METHOD_DESCRIPTIONS}
@app.get("/api/samples")
def samples() -> dict[str, Any]:
ensure_dirs()
items = []
for path in sorted(SAMPLE_DIR.glob("*")):
suffix = path.suffix.lower()
if suffix in IMAGE_SUFFIXES | VIDEO_SUFFIXES:
items.append(
{
"name": path.name,
"url": _public(path),
"kind": "image" if suffix in IMAGE_SUFFIXES else "video",
"size": path.stat().st_size,
}
)
return {"samples": items}
def _public(path: Path) -> str:
return "/" + path.relative_to(ROOT).as_posix()