Spaces:
Sleeping
Sleeping
Download app.py from ai4tp/launch-TP-Interact: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/ai4tp/launch-TP-Interact/resolve/main/app.py
- Command line
-
hf download hf://spaces/ai4tp/launch-TP-Interact/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ai4tp/launch-TP-Interact/resolve/main/app.py
725 Bytes
| import os | |
| import sys | |
| import subprocess | |
| import streamlit as st | |
| from huggingface_hub import snapshot_download | |
| def get_private_code(): | |
| local_dir = snapshot_download( | |
| repo_id=os.environ.get("HF_REPO"), | |
| token=os.environ.get("HF_TOKEN"), | |
| repo_type="space" | |
| ) | |
| with open(os.path.join(local_dir, "app.py"), "r", encoding="utf-8") as f: | |
| code = f.read() | |
| return code, local_dir | |
| try: | |
| code_content, private_dir = get_private_code() | |
| sys.path.append(private_dir) | |
| os.environ["PYTHONPATH"] = private_dir | |
| exec(compile(code_content, "internal_logic", "exec"), globals()) | |
| except Exception: | |
| st.error("Error! Check Repo and Token details.") |