Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
#
|
| 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 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 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 |
+
])
|