Spaces:
Running
Running
| from huggingface_hub import HfApi, login | |
| import sys | |
| def create_space(): | |
| # Get token from user | |
| token = input("Enter your Hugging Face access token (from https://huggingface.co/settings/tokens): ") | |
| # Login with token | |
| login(token=token) | |
| api = HfApi() | |
| # Get username | |
| username = input("Enter your Hugging Face username: ") | |
| space_name = "local-inference" | |
| space_id = f"{username}/{space_name}" | |
| print(f"Creating Space: {space_id}") | |
| try: | |
| api.create_repo( | |
| repo_id=space_id, | |
| repo_type="space", | |
| space_sdk="docker", | |
| ) | |
| print(f"\nSpace created successfully!") | |
| print(f"Remote URL: https://huggingface.co/spaces/{space_id}") | |
| print("\nNext steps:") | |
| print("1. Initialize git in this directory (if not already done)") | |
| print("2. Add the remote:") | |
| print(f" git remote add origin https://huggingface.co/spaces/{space_id}") | |
| print("3. Push your code:") | |
| print(" git add .") | |
| print(' git commit -m "Initial commit"') | |
| print(" git push -u origin main") | |
| except Exception as e: | |
| print(f"Error creating space: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| create_space() |