TransHub / upload_to_hf.py
linguabot's picture
Upload folder using huggingface_hub
4f163ba verified
raw
history blame
1.8 kB
#!/usr/bin/env python3
"""
Upload frontend files to Hugging Face Spaces
"""
import os
from huggingface_hub import HfApi
def upload_to_huggingface():
# Initialize the API
api = HfApi()
# Your Space name
repo_id = "TYU0053/transcreation-frontend"
# Files to upload (excluding node_modules and build)
files_to_upload = [
"Dockerfile",
"nginx.conf",
"package.json",
"package-lock.json",
"tailwind.config.js",
"tsconfig.json",
"postcss.config.js",
".gitignore"
]
# Upload individual files
for file in files_to_upload:
if os.path.exists(file):
print(f"Uploading {file}...")
api.upload_file(
path_or_fileobj=file,
path_in_repo=file,
repo_id=repo_id,
repo_type="space"
)
print(f"βœ… Uploaded {file}")
else:
print(f"❌ File not found: {file}")
# Upload src folder
if os.path.exists("src"):
print("Uploading src folder...")
api.upload_folder(
folder_path="src",
path_in_repo="src",
repo_id=repo_id,
repo_type="space"
)
print("βœ… Uploaded src folder")
# Upload public folder
if os.path.exists("public"):
print("Uploading public folder...")
api.upload_folder(
folder_path="public",
path_in_repo="public",
repo_id=repo_id,
repo_type="space"
)
print("βœ… Uploaded public folder")
print("\nπŸŽ‰ Upload complete!")
print(f"Your Space will be available at: https://huggingface.co/spaces/{repo_id}")
if __name__ == "__main__":
upload_to_huggingface()