INNER CODE UNIT · Python
_as_bool
Nour833/StegoForge · web/app.py:20
def _as_bool(form, key: str, default: bool = False) -> bool:
if key not in form:
return default
return str(form.get(key, "")).strip().lower() in {"1", "true", "yes", "on"}
def _json_sse(payload: dict) -> str:
return f"data: {json.dumps(payload)}\n\n"
def _artifact_allowed(path: Path) -> bool:
if not path.exists() or not path.is_file():
return False
if path.name.startswith(ARTIFACT_PREFIX):
return True
if path.name.endswith("_fingerprint_heatmap.png") and path.parent.resolve() == Path.cwd().resolve():
return True
return False