Spaces:
Runtime error
Runtime error
File size: 1,037 Bytes
9b68ed2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import os
import subprocess
import sys
# GitHub Repo Info
GITHUB_USERNAME = "DeYurt"
GITHUB_REPO = "Welcome_Call_Agent"
GITHUB_BRANCH = "main"
CODE_DIR = "/tmp/hidden_code"
HF_TOKEN = os.environ.get("GITHUB_TOKEN")
if HF_TOKEN is None:
raise RuntimeError("❌ Missing GITHUB_TOKEN in Hugging Face secrets!")
# Clone private repo if needed
if not os.path.exists(CODE_DIR):
repo_url = f"https://{HF_TOKEN}@github.com/{GITHUB_USERNAME}/{GITHUB_REPO}.git"
subprocess.run([
"git", "clone", "--depth", "1", "--branch", GITHUB_BRANCH, repo_url, CODE_DIR
], check=True, stdout=sys.stdout, stderr=sys.stderr)
# Final path to FastAPI entry point
api_script = os.path.join(CODE_DIR, "app.py")
if not os.path.exists(api_script):
raise FileNotFoundError("❌ hidden_code/app.py not found")
os.chdir(CODE_DIR) # Change to the hidden_code dir
os.environ["PYTHONPATH"] = CODE_DIR # Ensure Python can resolve imports
os.execvp("uvicorn", [
"uvicorn", "app:app",
"--host", "0.0.0.0",
"--port", "7860"
])
|