Spaces:
Runtime error
Runtime error
| from huggingface_hub import create_repo, get_full_repo_name | |
| import os | |
| import sys | |
| # 获取Space名称 | |
| if len(sys.argv) > 1: | |
| space_name = sys.argv[1] | |
| else: | |
| space_name = input("Enter your Space name (e.g. hf-proxy-panel): ") | |
| # 创建新的Space | |
| try: | |
| repo_id = create_repo( | |
| space_name, | |
| repo_type="space", | |
| space_sdk="gradio", # 这里有几个选项:gradio, streamlit, docker, static | |
| space_hardware="cpu-basic", # cpu-basic是免费的,其他选项包括cpu-upgrade, t4-small, a10g-small等 | |
| private=False | |
| ) | |
| print(f"✓ Space created successfully: {repo_id}") | |
| # 获取远程仓库URL | |
| username = repo_id.split('/')[0] | |
| full_repo_name = get_full_repo_name(space_name, token=None, organization=None) | |
| git_url = f"https://huggingface.co/spaces/{full_repo_name}" | |
| print(f"\nTo add the remote repository and push your code, run:") | |
| print(f"git remote add origin https://huggingface.co/spaces/{full_repo_name}") | |
| print(f"git push -u origin main") | |
| print(f"\nYour Space will be available at: {git_url}") | |
| except Exception as e: | |
| print(f"✗ Error creating Space: {str(e)}") | |
| sys.exit(1) | |