Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
#
|
| 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([
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
os.execvp("streamlit", [
|
| 21 |
-
"streamlit", "run",
|
| 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 |
])
|
|
|