DerYur commited on
Commit
1455d83
·
verified ·
1 Parent(s): aae7321

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -1,9 +1,8 @@
1
  import os
2
  import subprocess
3
- import sys
4
  import time
5
 
6
- # GitHub Repo Info
7
  GITHUB_USERNAME = "DeYurt"
8
  GITHUB_REPO = "Welcome_Call_Agent"
9
  GITHUB_BRANCH = "main"
@@ -13,20 +12,15 @@ 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
- # 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
  ])
 
 
1
  import os
2
  import subprocess
 
3
  import time
4
 
5
+ # Clone your private repo only (DO NOT launch Streamlit here!)
6
  GITHUB_USERNAME = "DeYurt"
7
  GITHUB_REPO = "Welcome_Call_Agent"
8
  GITHUB_BRANCH = "main"
 
12
  if HF_TOKEN is None:
13
  raise RuntimeError("❌ Missing GITHUB_TOKEN in Hugging Face secrets!")
14
 
 
15
  if not os.path.exists(CODE_DIR):
16
  repo_url = f"https://{HF_TOKEN}@github.com/{GITHUB_USERNAME}/{GITHUB_REPO}.git"
17
  subprocess.run(["git", "clone", "--depth", "1", "--branch", GITHUB_BRANCH, repo_url, CODE_DIR], check=True)
18
 
19
+ # Replace current app.py with hidden_code/app.py and re-run Streamlit
20
+ os.execvp("streamlit", [
21
+ "streamlit", "run", os.path.join(CODE_DIR, "app.py"),
 
 
 
 
 
22
  "--server.port=7860",
23
  "--server.headless=true",
24
+ "--server.address=0.0.0.0"
25
  ])
26
+