update
Browse files10 unmodified lines1112131415161710 unmodified lineshf_oauth: truehf_oauth_scopes: - write-repos - manage-repos---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference203 unmodified lines2042052062072082092102072082092102112122132122132142152162172182142152162172182192202212222233 unmodified lines227228229230231232233234229230231232233234235235236237238239240241242243244245246247248148 unmodified lines397398399400401402403404405406407408203 unmodified lines # Create API client with user token user_hf_api = HfApi(token=api_token) # Get the current user's username if not provided if not username: try: user_info = user_hf_api.whoami() # Debug: Test the token by getting user info try: user_info = user_hf_api.whoami() print(f"Debug: User info from API: {user_info}") if not username: username = user_info.get('name', 'user') print(f"Debug: Final username: {username}") except Exception as e: print(f"Could not get user info: {e}") return { "success": False, "error": "Invalid or expired token", "message": "Please check your Hugging Face token" } except Exception as e: print(f"Debug: Could not get user info: {e}") return { "success": False, "error": f"Invalid or expired token: {str(e)}", "message": "Please check your Hugging Face token and try logging in again" } # Clean the title for use as repo name clean_title = re.sub(r'[^a-zA-Z0-9_-]', '-', title.lower())3 unmodified lines timestamp = int(time.time()) repo_name = f"{username}/{clean_title}-{timestamp}" print(f"Debug: Attempting to create space: {repo_name}") print(f"Debug: Using token for user: {username}") # Create the space try: repo_url = user_hf_api.create_repo( repo_id=repo_name, repo_type="space", space_sdk="static", private=False, exist_ok=False ) repo_url = user_hf_api.create_repo( repo_id=repo_name, repo_type="space", space_sdk="static", private=False, exist_ok=False ) print(f"Debug: Successfully created space: {repo_url}") except Exception as e: print(f"Debug: Failed to create space: {e}") raise e # Prepare the HTML content with proper structure html_template = """<!DOCTYPE html>148 unmodified lines username = oauth_profile.name user_token = oauth_token.token # Debug: Print token info (without exposing the actual token) print(f"Debug: Username from OAuth: {username}") print(f"Debug: Token type: {type(user_token)}") print(f"Debug: Token length: {len(user_token) if user_token else 0}") print(f"Debug: Token starts with: {user_token[:10] if user_token else 'None'}...") # Extract prompts from history prompts = [] for user_msg, _ in history:README.md+1
app.py+34-18