Spaces:
Running
Running
Download upload_to_space.py from xwk123/mobileworldmodel: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/xwk123/mobileworldmodel/resolve/main/upload_to_space.py
- Command line
-
hf download hf://spaces/xwk123/mobileworldmodel/upload_to_space.py
-
curl -L -o upload_to_space.py https://huggingface.co/spaces/xwk123/mobileworldmodel/resolve/main/upload_to_space.py
1.09 kB
| #!/usr/bin/env python3 | |
| """Upload the static project page to a Hugging Face Space. | |
| Usage: | |
| export HF_TOKEN="hf_..." | |
| python3 hf_dataset_landing/upload_to_space.py | |
| Do not hard-code tokens in this file. | |
| """ | |
| from pathlib import Path | |
| import os | |
| from huggingface_hub import HfApi, create_repo | |
| REPO_ID = "xwk123/mobileworldmodel" | |
| REPO_TYPE = "space" | |
| def main() -> None: | |
| token = os.environ.get("HF_TOKEN") | |
| if not token: | |
| raise SystemExit("HF_TOKEN is not set. Run: export HF_TOKEN='hf_...'") | |
| folder = Path(__file__).resolve().parent | |
| create_repo( | |
| repo_id=REPO_ID, | |
| repo_type=REPO_TYPE, | |
| space_sdk="static", | |
| exist_ok=True, | |
| token=token, | |
| ) | |
| HfApi(token=token).upload_folder( | |
| folder_path=str(folder), | |
| repo_id=REPO_ID, | |
| repo_type=REPO_TYPE, | |
| commit_message="Add MobileWorldModel static project page", | |
| ) | |
| print(f"Uploaded {folder} to https://huggingface.co/spaces/{REPO_ID}") | |
| print(f"Space URL: https://{REPO_ID.replace('/', '-')}.hf.space") | |
| if __name__ == "__main__": | |
| main() | |