llbba's picture
Update app.py
8500fe0 verified
Raw History Blame Contribute Delete
930 Bytes
# app.py (Inside your PUBLIC Space)
import os
import sys
from huggingface_hub import snapshot_download
# 1. Fetch the secure token from the environment secrets
HF_TOKEN = os.environ.get("HF_TOKEN")
if not HF_TOKEN:
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("## ❌ Configuration Error: Missing Secret Token.")
demo.launch()
else:
# 2. Safely clone your private repo files directly into the running instance container
# Replace 'your-username/my-secret-logic' with your actual private space path
local_dir = snapshot_download(
repo_id="llbba/core",
repo_type="space",
token=HF_TOKEN
)
# 3. Add the temporary downloaded path to Python's look-up engine
sys.path.insert(0, local_dir)
# 4. Import your app structure from the downloaded files and start it
from main_app import create_ui
demo = create_ui()
demo.launch()