Spaces:
Running
Running
Download deploy_to_hf.py from bllndebrahim/translet: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/bllndebrahim/translet/resolve/main/deploy_to_hf.py
- Command line
-
hf download hf://spaces/bllndebrahim/translet/deploy_to_hf.py
-
curl -L -o deploy_to_hf.py https://huggingface.co/spaces/bllndebrahim/translet/resolve/main/deploy_to_hf.py
1.48 kB
| import sys | |
| import os | |
| from huggingface_hub import HfApi | |
| def deploy(token, username="bl1ndebrahim", repo_name="translet"): | |
| api = HfApi(token=token) | |
| user_info = api.whoami() | |
| actual_username = user_info.get("name", username) | |
| repo_id = f"{actual_username}/{repo_name}" | |
| print(f"Logged in as: {actual_username}") | |
| print(f"Creating/verifying Space: {repo_id} ...") | |
| api.create_repo( | |
| repo_id=repo_id, | |
| repo_type="space", | |
| space_sdk="docker", | |
| exist_ok=True | |
| ) | |
| print("Uploading project files to Hugging Face Space ...") | |
| ignore = [ | |
| "*.exe", "*.log", "*.pid", "__pycache__/*", "*.pyc", | |
| "audio_cache/*", "test_*.wav", "test_*.mp3", "compare_*.wav", | |
| "vits_*.wav", "debug_*.wav", "truly_*.wav", "kurdish_vocalized_sample.wav", | |
| ".git/*", ".gemini/*" | |
| ] | |
| api.upload_folder( | |
| folder_path=".", | |
| repo_id=repo_id, | |
| repo_type="space", | |
| ignore_patterns=ignore | |
| ) | |
| subdomain = f"{actual_username.replace('_', '-')}-{repo_name.replace('_', '-')}".lower() | |
| direct_url = f"https://{subdomain}.hf.space" | |
| space_page = f"https://huggingface.co/spaces/{repo_id}" | |
| print(f"\nSUCCESS! Deployment uploaded successfully!") | |
| print(f"Space Page: {space_page}") | |
| print(f"Direct App URL: {direct_url}") | |
| if __name__ == "__main__": | |
| if len(sys.argv) > 1: | |
| deploy(sys.argv[1].strip()) | |
| else: | |
| print("Usage: python deploy_to_hf.py <HF_TOKEN>") | |