Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -190,6 +190,35 @@ def create_ui():
|
|
190 |
height: 600px;
|
191 |
border: none;
|
192 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
"""
|
194 |
|
195 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
@@ -221,17 +250,34 @@ def create_ui():
|
|
221 |
with gr.Group(elem_classes="output-group"):
|
222 |
app_py_content = gr.Code(language="python", label="๋ฉ์ธ ์์ค์ฝ๋", elem_id="app-py-content", lines=None, max_lines=None)
|
223 |
|
224 |
-
#
|
225 |
embedded_space = gr.HTML(
|
226 |
"""
|
227 |
-
<
|
228 |
-
|
|
|
|
|
|
|
229 |
<script>
|
230 |
-
function
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
</script>
|
237 |
"""
|
@@ -242,7 +288,7 @@ def create_ui():
|
|
242 |
def update_embedded_space(url):
|
243 |
return f"""
|
244 |
<script>
|
245 |
-
|
246 |
</script>
|
247 |
"""
|
248 |
|
@@ -262,7 +308,6 @@ def create_ui():
|
|
262 |
)
|
263 |
|
264 |
|
265 |
-
|
266 |
def refresh_screenshot(url, last_url):
|
267 |
print(f"Refresh button clicked. URL: {url}, Last URL: {last_url}")
|
268 |
return update_screenshot(url, last_url)
|
|
|
190 |
height: 600px;
|
191 |
border: none;
|
192 |
}
|
193 |
+
.iframe-container {
|
194 |
+
position: relative;
|
195 |
+
width: 100%;
|
196 |
+
height: 600px;
|
197 |
+
overflow: hidden;
|
198 |
+
}
|
199 |
+
.iframe-container iframe {
|
200 |
+
width: 100%;
|
201 |
+
height: 100%;
|
202 |
+
border: none;
|
203 |
+
}
|
204 |
+
.loading-overlay {
|
205 |
+
position: absolute;
|
206 |
+
top: 0;
|
207 |
+
left: 0;
|
208 |
+
width: 100%;
|
209 |
+
height: 100%;
|
210 |
+
background-color: rgba(255, 255, 255, 0.8);
|
211 |
+
display: flex;
|
212 |
+
justify-content: center;
|
213 |
+
align-items: center;
|
214 |
+
font-size: 24px;
|
215 |
+
z-index: 1000;
|
216 |
+
}
|
217 |
+
.error-message {
|
218 |
+
color: red;
|
219 |
+
font-weight: bold;
|
220 |
+
text-align: center;
|
221 |
+
}
|
222 |
"""
|
223 |
|
224 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
|
|
250 |
with gr.Group(elem_classes="output-group"):
|
251 |
app_py_content = gr.Code(language="python", label="๋ฉ์ธ ์์ค์ฝ๋", elem_id="app-py-content", lines=None, max_lines=None)
|
252 |
|
253 |
+
# iframe์ ์ํ HTML ์์
|
254 |
embedded_space = gr.HTML(
|
255 |
"""
|
256 |
+
<div class="iframe-container">
|
257 |
+
<div id="loading-overlay" class="loading-overlay">๋ก๋ฉ ์ค...</div>
|
258 |
+
<iframe id="space-iframe" src="about:blank" onload="hideLoading()"></iframe>
|
259 |
+
</div>
|
260 |
+
<div id="error-message" class="error-message"></div>
|
261 |
<script>
|
262 |
+
function hideLoading() {
|
263 |
+
document.getElementById('loading-overlay').style.display = 'none';
|
264 |
+
}
|
265 |
+
function showLoading() {
|
266 |
+
document.getElementById('loading-overlay').style.display = 'flex';
|
267 |
+
}
|
268 |
+
function updateIframe(url) {
|
269 |
+
showLoading();
|
270 |
+
const iframe = document.getElementById('space-iframe');
|
271 |
+
const errorMessage = document.getElementById('error-message');
|
272 |
+
iframe.src = url;
|
273 |
+
iframe.onload = function() {
|
274 |
+
hideLoading();
|
275 |
+
errorMessage.textContent = '';
|
276 |
+
};
|
277 |
+
iframe.onerror = function() {
|
278 |
+
hideLoading();
|
279 |
+
errorMessage.textContent = 'Space๋ฅผ ๋ก๋ํ๋ ๋ฐ ์คํจํ์ต๋๋ค. ์ ํญ์์ ์ด์ด๋ณด์ธ์.';
|
280 |
+
};
|
281 |
}
|
282 |
</script>
|
283 |
"""
|
|
|
288 |
def update_embedded_space(url):
|
289 |
return f"""
|
290 |
<script>
|
291 |
+
updateIframe("{url}");
|
292 |
</script>
|
293 |
"""
|
294 |
|
|
|
308 |
)
|
309 |
|
310 |
|
|
|
311 |
def refresh_screenshot(url, last_url):
|
312 |
print(f"Refresh button clicked. URL: {url}, Last URL: {last_url}")
|
313 |
return update_screenshot(url, last_url)
|