awacke1 commited on
Commit
2e42b59
·
1 Parent(s): 17a7688

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -185,12 +185,15 @@ def main():
185
  for i, data in enumerate(url_data):
186
  col = cols[i % num_cols]
187
  with col:
188
- if st.button(f"{emoji} {name}", key=url): # using the URL as the unique key
189
- # Open the URL in a new browser tab using JavaScript
190
- st.write('<script>window.open("'+data['url']+'", "_blank");</script>', unsafe_allow_html=True)
191
- # Update the history of clicks
192
- history[data['url']] += 1
193
- save_history(history)
 
 
 
194
  # Display the number of times the URL was opened below its corresponding button
195
  st.write(f"Clicked: {history[data['url']]} times")
196
 
 
185
  for i, data in enumerate(url_data):
186
  col = cols[i % num_cols]
187
  with col:
188
+ try: # and figure out a solution to the duplicate key problem ;)
189
+ if st.button(f"{emoji} {name}", key=url): # using the URL as the unique key
190
+ # Open the URL in a new browser tab using JavaScript
191
+ st.write('<script>window.open("'+data['url']+'", "_blank");</script>', unsafe_allow_html=True)
192
+ # Update the history of clicks
193
+ history[data['url']] += 1
194
+ save_history(history)
195
+ except:
196
+ st.write('Keep Trying ;)')
197
  # Display the number of times the URL was opened below its corresponding button
198
  st.write(f"Clicked: {history[data['url']]} times")
199