2026-05-18-19-06-50 构建网页端分割工作台
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user