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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -1,8 +1,8 @@
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,15 +12,22 @@ HF_TOKEN = os.environ.get("GITHUB_TOKEN")
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
-
 
1
  import os
2
  import subprocess
3
+ import sys
4
 
5
+ # GitHub Repo Info
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
+ # Clone private repo if needed
16
  if not os.path.exists(CODE_DIR):
17
  repo_url = f"https://{HF_TOKEN}@github.com/{GITHUB_USERNAME}/{GITHUB_REPO}.git"
18
+ subprocess.run([
19
+ "git", "clone", "--depth", "1", "--branch", GITHUB_BRANCH, repo_url, CODE_DIR
20
+ ], check=True)
21
 
22
+ # Final path to Streamlit entry point
23
+ streamlit_script = os.path.join(CODE_DIR, "app.py")
24
+ if not os.path.exists(streamlit_script):
25
+ raise FileNotFoundError("❌ hidden_code/app.py not found")
26
+
27
+ # Replace current process with Streamlit (foreground!)
28
  os.execvp("streamlit", [
29
+ "streamlit", "run", streamlit_script,
30
  "--server.port=7860",
31
  "--server.headless=true",
32
  "--server.address=0.0.0.0"
33
  ])