Minimal-Maximal / app.py
ThisIsAnAnonymousUser's picture
Update app.py
31f08fe verified
Raw History Blame Contribute Delete
1.1 kB
import os
import sys
import zipfile
from huggingface_hub import hf_hub_download
# ---- Your private code vault (dataset repo) ----
CODE_REPO = "ThisIsAnAnonymousUser/minmax-code-private"
CODE_ZIP = "private_app.zip"
def load_private_app():
token = os.getenv("HF_TOKEN")
if not token:
raise RuntimeError("HF_TOKEN secret missing. Add it in Space Settings → Secrets.")
zip_path = hf_hub_download(
repo_id=CODE_REPO,
filename=CODE_ZIP,
repo_type="dataset",
token=token,
)
extract_dir = "/tmp/private_app"
os.makedirs(extract_dir, exist_ok=True)
with zipfile.ZipFile(zip_path, "r") as z:
z.extractall(extract_dir)
sys.path.insert(0, extract_dir)
import private_app # this comes from private_app.py inside the zip
return private_app
private_app = load_private_app()
# Launch the real app (kept private in the zip)
if __name__ == "__main__":
private_app.demo.queue()
port = int(os.environ.get("PORT", "7860"))
private_app.demo.launch(server_name="0.0.0.0", server_port=port, ssr_mode=False)