DerYur commited on
Commit
9c5f0d8
·
verified ·
1 Parent(s): 99e364c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
- import sys
3
  import subprocess
 
4
  import time
5
 
6
  # GitHub Repo Info
@@ -13,19 +13,20 @@ HF_TOKEN = os.environ.get("GITHUB_TOKEN")
13
  if HF_TOKEN is None:
14
  raise RuntimeError("❌ Missing GITHUB_TOKEN in Hugging Face secrets!")
15
 
16
- # Only clone if CODE_DIR doesn't exist
17
  if not os.path.exists(CODE_DIR):
18
  repo_url = f"https://{HF_TOKEN}@github.com/{GITHUB_USERNAME}/{GITHUB_REPO}.git"
19
- subprocess.run([
20
- "git", "clone", "--depth", "1", "--branch", GITHUB_BRANCH, repo_url, CODE_DIR
21
- ], check=True)
22
- time.sleep(1)
23
 
 
 
 
 
24
 
25
- # Run the hidden_code app
26
- main_app = os.path.join(CODE_DIR, "app.py")
27
- if os.path.exists(main_app):
28
- sys.path.insert(0, CODE_DIR)
29
- exec(open(main_app).read(), globals())
30
- else:
31
- raise FileNotFoundError("❌ hidden_code/app.py not found")
 
1
  import os
 
2
  import subprocess
3
+ import sys
4
  import time
5
 
6
  # GitHub Repo Info
 
13
  if HF_TOKEN is None:
14
  raise RuntimeError("❌ Missing GITHUB_TOKEN in Hugging Face secrets!")
15
 
16
+ # Clone the repo if not already there
17
  if not os.path.exists(CODE_DIR):
18
  repo_url = f"https://{HF_TOKEN}@github.com/{GITHUB_USERNAME}/{GITHUB_REPO}.git"
19
+ subprocess.run(["git", "clone", "--depth", "1", "--branch", GITHUB_BRANCH, repo_url, CODE_DIR], check=True)
 
 
 
20
 
21
+ # Run the Streamlit app as the ONLY foreground process (so HF sees it)
22
+ streamlit_script = os.path.join(CODE_DIR, "app.py")
23
+ if not os.path.exists(streamlit_script):
24
+ raise FileNotFoundError("❌ hidden_code/app.py not found")
25
 
26
+ # Launch Streamlit directly
27
+ subprocess.run([
28
+ "streamlit", "run", streamlit_script,
29
+ "--server.port=7860",
30
+ "--server.headless=true",
31
+ "--server.address=0.0.0.0" # <--- 🔥 IMPORTANT FIX!
32
+ ])