Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -226,11 +226,26 @@ def create_ui():
|
|
226 |
"""
|
227 |
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.36.1/gradio.js"></script>
|
228 |
<gradio-app id="embedded-gradio-app" style="width:100%;height:600px;"></gradio-app>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
"""
|
230 |
)
|
231 |
|
232 |
update_trigger = gr.Button("Update Screenshot", visible=False)
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
for _, button, space in space_rows:
|
235 |
button.click(
|
236 |
lambda s=space: on_select(s),
|
@@ -241,16 +256,13 @@ def create_ui():
|
|
241 |
inputs=[url_state, last_url_state],
|
242 |
outputs=[screenshot_output, last_url_state]
|
243 |
).then(
|
244 |
-
|
245 |
-
<script>
|
246 |
-
document.getElementById('embedded-gradio-app').setAttribute('src', '{url}');
|
247 |
-
</script>
|
248 |
-
""",
|
249 |
inputs=[url_state],
|
250 |
outputs=[embedded_space]
|
251 |
)
|
252 |
|
253 |
|
|
|
254 |
def refresh_screenshot(url, last_url):
|
255 |
print(f"Refresh button clicked. URL: {url}, Last URL: {last_url}")
|
256 |
return update_screenshot(url, last_url)
|
|
|
226 |
"""
|
227 |
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.36.1/gradio.js"></script>
|
228 |
<gradio-app id="embedded-gradio-app" style="width:100%;height:600px;"></gradio-app>
|
229 |
+
<script>
|
230 |
+
function updateGradioApp(url) {
|
231 |
+
const app = document.getElementById('embedded-gradio-app');
|
232 |
+
if (app) {
|
233 |
+
app.setAttribute('src', url);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
</script>
|
237 |
"""
|
238 |
)
|
239 |
|
240 |
update_trigger = gr.Button("Update Screenshot", visible=False)
|
241 |
|
242 |
+
def update_embedded_space(url):
|
243 |
+
return f"""
|
244 |
+
<script>
|
245 |
+
updateGradioApp("{url}");
|
246 |
+
</script>
|
247 |
+
"""
|
248 |
+
|
249 |
for _, button, space in space_rows:
|
250 |
button.click(
|
251 |
lambda s=space: on_select(s),
|
|
|
256 |
inputs=[url_state, last_url_state],
|
257 |
outputs=[screenshot_output, last_url_state]
|
258 |
).then(
|
259 |
+
update_embedded_space,
|
|
|
|
|
|
|
|
|
260 |
inputs=[url_state],
|
261 |
outputs=[embedded_space]
|
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)
|