Spaces:
Runtime error
Runtime error
| import os | |
| import sys | |
| import importlib.util | |
| import shutil | |
| from huggingface_hub import snapshot_download | |
| # 1. Configuration | |
| PRIVATE_REPO = "hemann/bus-tracker" | |
| # Use /tmp/ to hide files from the HF Watchdog | |
| TEMP_DIR = "/tmp/private_content" | |
| token = os.environ.get("HF_TOKEN") | |
| # 2. Check if already downloaded in /tmp | |
| if not os.path.exists(TEMP_DIR): | |
| print(f"Downloading to secure temp location...") | |
| snapshot_download( | |
| repo_id=PRIVATE_REPO, | |
| repo_type="space", | |
| local_dir=TEMP_DIR, | |
| token=token, | |
| ignore_patterns=["app.py"] | |
| ) | |
| else: | |
| print("Files already secured in temp storage.") | |
| # 3. Setup Environment | |
| # Add temp dir to path so imports work | |
| sys.path.append(TEMP_DIR) | |
| # Change working directory so your code finds its JSON/CSV files | |
| os.chdir(TEMP_DIR) | |
| # 4. Execute the private main file | |
| # Replace 'main_logic.py' with the actual name of your private entry file | |
| PRIVATE_MAIN = "appp.py" | |
| spec = importlib.util.spec_from_file_location("private_app", PRIVATE_MAIN) | |
| module = importlib.util.module_from_spec(spec) | |
| sys.modules["private_app"] = module | |
| spec.loader.exec_module(module) | |