INNER CODE UNIT · Python
_static_path
mars-tw/anti-gambling-trader-tw · core/ui/server.py:106
def _static_path(name: str) -> Path:
return Path(__file__).resolve().parent / "static" / name
def _ascii_download_name(filename: str) -> str:
normalized = unicodedata.normalize("NFKD", filename)
raw = normalized.encode("ascii", "ignore").decode("ascii")
safe = re.sub(r"[^A-Za-z0-9._-]+", "_", raw).strip("._")
suffix = Path(filename).suffix.lower()
ascii_suffix = re.sub(r"[^A-Za-z0-9.]", "", suffix)
if not safe:
safe = f"download{ascii_suffix or '.bin'}"
elif "." not in safe and ascii_suffix:
safe = f"download{ascii_suffix}"
return safe[:100]
def _artifact_payload(artifact: Artifact) -> dict[str, str]: