Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -4,19 +4,24 @@ import dash_bootstrap_components as dbc
|
|
4 |
import uuid
|
5 |
import json
|
6 |
import os
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
9 |
|
10 |
-
|
11 |
|
12 |
def load_links():
|
13 |
-
if os.path.exists(
|
14 |
-
with open(
|
15 |
return json.load(f)
|
16 |
return []
|
17 |
|
18 |
def save_links(links):
|
19 |
-
with open(
|
20 |
json.dump(links, f)
|
21 |
|
22 |
def generate_url_list(links):
|
@@ -82,8 +87,8 @@ app.layout = dbc.Container([
|
|
82 |
def toggle_modal(n1, n2, is_open):
|
83 |
if n1 or n2:
|
84 |
if is_open:
|
85 |
-
return False, '', ''
|
86 |
-
return True, dash.no_update, dash.no_update
|
87 |
return is_open, dash.no_update, dash.no_update
|
88 |
|
89 |
@callback(
|
@@ -127,6 +132,7 @@ def update_url_list(trigger_load, add_clicks, delete_clicks, new_name, new_link)
|
|
127 |
status = 'deleted'
|
128 |
|
129 |
url_list = generate_url_list(links)
|
|
|
130 |
return url_list, feedback, status
|
131 |
|
132 |
@callback(
|
@@ -148,6 +154,6 @@ def update_iframe(n_clicks):
|
|
148 |
|
149 |
if __name__ == '__main__':
|
150 |
print("Starting the Dash application...")
|
151 |
-
print(f"
|
152 |
app.run(debug=True, host='0.0.0.0', port=7860)
|
153 |
print("Dash application has finished running.")
|
|
|
4 |
import uuid
|
5 |
import json
|
6 |
import os
|
7 |
+
import requests
|
8 |
+
from urllib3.exceptions import InsecureRequestWarning
|
9 |
+
|
10 |
+
# Disable SSL warnings
|
11 |
+
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
|
12 |
|
13 |
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
14 |
|
15 |
+
JSON_FILE = 'app.json'
|
16 |
|
17 |
def load_links():
|
18 |
+
if os.path.exists(JSON_FILE):
|
19 |
+
with open(JSON_FILE, 'r') as f:
|
20 |
return json.load(f)
|
21 |
return []
|
22 |
|
23 |
def save_links(links):
|
24 |
+
with open(JSON_FILE, 'w') as f:
|
25 |
json.dump(links, f)
|
26 |
|
27 |
def generate_url_list(links):
|
|
|
87 |
def toggle_modal(n1, n2, is_open):
|
88 |
if n1 or n2:
|
89 |
if is_open:
|
90 |
+
return False, '', '' # Close modal and reset input fields
|
91 |
+
return True, dash.no_update, dash.no_update # Open modal
|
92 |
return is_open, dash.no_update, dash.no_update
|
93 |
|
94 |
@callback(
|
|
|
132 |
status = 'deleted'
|
133 |
|
134 |
url_list = generate_url_list(links)
|
135 |
+
|
136 |
return url_list, feedback, status
|
137 |
|
138 |
@callback(
|
|
|
154 |
|
155 |
if __name__ == '__main__':
|
156 |
print("Starting the Dash application...")
|
157 |
+
print(f"JSON file location: {os.path.abspath(JSON_FILE)}")
|
158 |
app.run(debug=True, host='0.0.0.0', port=7860)
|
159 |
print("Dash application has finished running.")
|