ThisIsAnAnonymousUser commited on
Commit
8226b0b
·
verified ·
1 Parent(s): b110939

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import zipfile
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # ---- Your private code vault (dataset repo) ----
7
+ CODE_REPO = "SarahMbi/minmax-code-private"
8
+ CODE_ZIP = "private_app.zip"
9
+
10
+ def load_private_app():
11
+ token = os.getenv("HF_TOKEN")
12
+ if not token:
13
+ raise RuntimeError("HF_TOKEN secret missing. Add it in Space Settings → Secrets.")
14
+
15
+ zip_path = hf_hub_download(
16
+ repo_id=CODE_REPO,
17
+ filename=CODE_ZIP,
18
+ repo_type="dataset",
19
+ token=token,
20
+ )
21
+
22
+ extract_dir = "/tmp/private_app"
23
+ os.makedirs(extract_dir, exist_ok=True)
24
+
25
+ with zipfile.ZipFile(zip_path, "r") as z:
26
+ z.extractall(extract_dir)
27
+
28
+ sys.path.insert(0, extract_dir)
29
+ import private_app # this comes from private_app.py inside the zip
30
+ return private_app
31
+
32
+ private_app = load_private_app()
33
+
34
+ # Launch the real app (kept private in the zip)
35
+ if __name__ == "__main__":
36
+ private_app.demo.queue()
37
+ port = int(os.environ.get("PORT", "7860"))
38
+ private_app.demo.launch(server_name="0.0.0.0", server_port=port, ssr_mode=False)