Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
189 |
-
#
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
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 |
|