bluenevus commited on
Commit
4d5516b
·
verified ·
1 Parent(s): 066dd67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -32,6 +32,25 @@ def get_links():
32
  print(f"Retrieved links: {links}") # Debug print
33
  return links
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  app.layout = dbc.Container([
36
  dcc.Store(id='add-url-status', data=''),
37
  dbc.Modal([
@@ -49,10 +68,16 @@ app.layout = dbc.Container([
49
  dbc.Col([
50
  html.H2("My URL App", className="mt-3 mb-4"),
51
  dbc.Button("Add URL", id="open-modal-button", color="primary", className="mb-3"),
52
- html.Div(id='url-list'),
53
  ], width=3, className="bg-light p-3"),
54
  dbc.Col([
55
- html.Iframe(id='content-iframe', style={'width': '100%', 'height': '800px'}, sandbox="allow-scripts allow-same-origin")
 
 
 
 
 
 
56
  ], width=9)
57
  ])
58
  ], fluid=True)
@@ -112,23 +137,7 @@ def update_url_list(add_clicks, status, delete_clicks, new_name, new_link):
112
  status = ''
113
 
114
  links = get_links()
115
- url_list = [
116
- dbc.ListGroupItem([
117
- dbc.Button(
118
- link['name'],
119
- id={'type': 'url-button', 'index': link['id']},
120
- color="link",
121
- className="text-left"
122
- ),
123
- html.Span(
124
- "✕",
125
- id={'type': 'delete-button', 'index': link['id']},
126
- className="float-right text-danger",
127
- style={"cursor": "pointer"}
128
- )
129
- ], className="d-flex justify-content-between align-items-center")
130
- for link in links
131
- ]
132
 
133
  return url_list, feedback, status
134
 
 
32
  print(f"Retrieved links: {links}") # Debug print
33
  return links
34
 
35
+ def generate_url_list(links):
36
+ return [
37
+ dbc.ListGroupItem([
38
+ dbc.Button(
39
+ link['name'],
40
+ id={'type': 'url-button', 'index': link['id']},
41
+ color="link",
42
+ className="text-left"
43
+ ),
44
+ html.Span(
45
+ "✕",
46
+ id={'type': 'delete-button', 'index': link['id']},
47
+ className="float-right text-danger",
48
+ style={"cursor": "pointer"}
49
+ )
50
+ ], className="d-flex justify-content-between align-items-center")
51
+ for link in links
52
+ ]
53
+
54
  app.layout = dbc.Container([
55
  dcc.Store(id='add-url-status', data=''),
56
  dbc.Modal([
 
68
  dbc.Col([
69
  html.H2("My URL App", className="mt-3 mb-4"),
70
  dbc.Button("Add URL", id="open-modal-button", color="primary", className="mb-3"),
71
+ html.Div(id='url-list', children=generate_url_list(get_links())),
72
  ], width=3, className="bg-light p-3"),
73
  dbc.Col([
74
+ html.Iframe(
75
+ id='content-iframe',
76
+ style={'width': '100%', 'height': '800px'},
77
+ sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-downloads",
78
+ allow="fullscreen; geolocation; microphone; camera; midi; encrypted-media; autoplay",
79
+ referrerPolicy="no-referrer"
80
+ )
81
  ], width=9)
82
  ])
83
  ], fluid=True)
 
137
  status = ''
138
 
139
  links = get_links()
140
+ url_list = generate_url_list(links)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  return url_list, feedback, status
143