MySafeCode commited on
Commit
598011b
·
verified ·
1 Parent(s): 155144b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +37 -19
index.html CHANGED
@@ -84,24 +84,42 @@
84
  </div>
85
 
86
  <script>
87
- // Auto-calculate the iframe URL based on current location
88
- const currentUrl = window.location.href;
89
- const baseUrl = currentUrl.split('/').slice(0, -1).join('/');
90
- const iframe = document.querySelector('iframe');
91
-
92
- // Set iframe source to the Gradio app
93
- // In Spaces, the Gradio app would be available at the same domain
94
- iframe.src = window.location.href.replace('https://1hit.no/audio/suno/';
95
-
96
- // Or if the Gradio app is running on a different port (for local testing):
97
- // iframe.src = 'http://localhost:7860';
98
-
99
- // Handle iframe loading messages
100
- window.addEventListener('message', function(event) {
101
- if (event.data && event.data.type === 'gradio_height') {
102
- iframe.style.height = event.data.height + 'px';
103
- }
104
- });
105
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  </body>
107
  </html>
 
84
  </div>
85
 
86
  <script>
87
+ // Get the current URL
88
+ const currentUrl = window.location.href;
89
+ const iframe = document.querySelector('iframe');
90
+
91
+ // Option 1: If you want to load an external URL (your https://1hit.no/audio/suno/)
92
+ iframe.src = 'https://1hit.no/audio/suno/';
93
+
94
+ // Option 2: If you want to load your Gradio app (running in the same Space)
95
+ // iframe.src = currentUrl; // This would load the current page in the iframe (might create a loop)
96
+ // iframe.src = currentUrl + 'app'; // Try this if Gradio is at /app endpoint
97
+
98
+ // Option 3: If your Gradio app runs on a specific port within the Space
99
+ // iframe.src = 'https://huggingface.co/spaces/MySafeCode/RepurposedSunoCoverPlayer/app';
100
+
101
+ // Handle iframe loading messages for dynamic height
102
+ window.addEventListener('message', function(event) {
103
+ if (event.data && event.data.type === 'gradio_height') {
104
+ iframe.style.height = event.data.height + 'px';
105
+ }
106
+ });
107
+
108
+ // Add error handling
109
+ iframe.onload = function() {
110
+ console.log('Iframe loaded successfully');
111
+ };
112
+
113
+ iframe.onerror = function() {
114
+ console.error('Failed to load iframe content');
115
+ // Show a fallback message
116
+ document.querySelector('.app-frame').innerHTML =
117
+ '<div style="padding: 40px; text-align: center; color: #666;">' +
118
+ '<h3>⚠️ Content Failed to Load</h3>' +
119
+ '<p>The embedded application could not be loaded.</p>' +
120
+ '<p><a href="https://1hit.no/audio/suno/" target="_blank">Click here to open in a new tab</a></p>' +
121
+ '</div>';
122
+ };
123
+ </script>
124
  </body>
125
  </html>