Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,8 @@ app.layout = dbc.Container([
|
|
47 |
style={'width': '100%', 'height': '800px'},
|
48 |
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-downloads",
|
49 |
allow="fullscreen; geolocation; microphone; camera; midi; encrypted-media; autoplay",
|
50 |
-
referrerPolicy="no-referrer"
|
|
|
51 |
)
|
52 |
], width=10, className="bg-white")
|
53 |
])
|
@@ -67,11 +68,17 @@ def update_url_list(_):
|
|
67 |
Input({'type': 'url-button', 'index': dash.ALL}, 'n_clicks'),
|
68 |
prevent_initial_call=True
|
69 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
def update_iframe(*n_clicks):
|
71 |
ctx = dash.callback_context
|
72 |
if not ctx.triggered:
|
73 |
print("No button clicked")
|
74 |
-
return dash.no_update
|
75 |
|
76 |
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
77 |
clicked_id = eval(button_id)['index']
|
@@ -80,11 +87,12 @@ def update_iframe(*n_clicks):
|
|
80 |
links = load_links()
|
81 |
for link in links:
|
82 |
if link['id'] == clicked_id:
|
83 |
-
|
84 |
-
|
|
|
85 |
|
86 |
print("No matching URL found")
|
87 |
-
return dash.no_update
|
88 |
|
89 |
if __name__ == '__main__':
|
90 |
print("Starting the Dash application...")
|
|
|
47 |
style={'width': '100%', 'height': '800px'},
|
48 |
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-downloads",
|
49 |
allow="fullscreen; geolocation; microphone; camera; midi; encrypted-media; autoplay",
|
50 |
+
referrerPolicy="no-referrer",
|
51 |
+
key='' # Add this line
|
52 |
)
|
53 |
], width=10, className="bg-white")
|
54 |
])
|
|
|
68 |
Input({'type': 'url-button', 'index': dash.ALL}, 'n_clicks'),
|
69 |
prevent_initial_call=True
|
70 |
)
|
71 |
+
@callback(
|
72 |
+
[Output('content-iframe', 'src'),
|
73 |
+
Output('content-iframe', 'key')], # Add a key output to force refresh
|
74 |
+
Input({'type': 'url-button', 'index': dash.ALL}, 'n_clicks'),
|
75 |
+
prevent_initial_call=True
|
76 |
+
)
|
77 |
def update_iframe(*n_clicks):
|
78 |
ctx = dash.callback_context
|
79 |
if not ctx.triggered:
|
80 |
print("No button clicked")
|
81 |
+
return dash.no_update, dash.no_update
|
82 |
|
83 |
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
84 |
clicked_id = eval(button_id)['index']
|
|
|
87 |
links = load_links()
|
88 |
for link in links:
|
89 |
if link['id'] == clicked_id:
|
90 |
+
url = link['url']
|
91 |
+
print(f"Loading URL: {url}")
|
92 |
+
return url, url # Return URL for both src and key
|
93 |
|
94 |
print("No matching URL found")
|
95 |
+
return dash.no_update, dash.no_update
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
print("Starting the Dash application...")
|