Spaces:
Paused
Paused
Download app.py from aabiro/MCP-Explorer: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/aabiro/MCP-Explorer/resolve/main/app.py
- Command line
-
hf download hf://spaces/aabiro/MCP-Explorer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aabiro/MCP-Explorer/resolve/main/app.py
1.28 kB
| """Thin public loader for this Space. | |
| The real application code for this Space is not public. It lives in a | |
| private Hugging Face repo and is downloaded at startup using this | |
| Space's HF_TOKEN secret. Only this loader file is public. | |
| """ | |
| import os | |
| import sys | |
| import zipfile | |
| from pathlib import Path | |
| PAYLOAD_REPO = "aabiro/space-payloads" | |
| PAYLOAD_FILE = "mcp-explorer.zip" | |
| TARGET = Path("/tmp/space-app/mcp-explorer") | |
| def _fetch_payload() -> None: | |
| if (TARGET / "app.py").is_file(): | |
| return | |
| token = os.environ.get("HF_TOKEN") | |
| if not token: | |
| raise RuntimeError( | |
| "HF_TOKEN secret is not set on this Space, so the private " | |
| "application code cannot be downloaded." | |
| ) | |
| from huggingface_hub import hf_hub_download | |
| zip_path = hf_hub_download( | |
| repo_id=PAYLOAD_REPO, | |
| repo_type="model", | |
| filename=PAYLOAD_FILE, | |
| token=token, | |
| ) | |
| TARGET.mkdir(parents=True, exist_ok=True) | |
| with zipfile.ZipFile(zip_path) as zf: | |
| zf.extractall(TARGET) | |
| _fetch_payload() | |
| sys.path.insert(0, str(TARGET)) | |
| os.chdir(TARGET) | |
| _app_file = TARGET / "app.py" | |
| exec( | |
| compile(_app_file.read_text(encoding="utf-8"), str(_app_file), "exec"), | |
| {"__name__": "__main__", "__file__": str(_app_file)}, | |
| ) | |