awacke1 commited on
Commit
da0f43e
ยท
verified ยท
1 Parent(s): 6282e22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -10
app.py CHANGED
@@ -5,15 +5,46 @@ import streamlit.components.v1 as components
5
  # Load the dataset
6
  dataset = load_dataset("awacke1/DatasetOfDatasetsUSA")
7
 
8
- # Assuming the dataset has a column 'url' that contains the link to the datasets
9
- # and a column 'title' for the text to display
10
- links_html = "<ul>"
11
- for item in dataset['train']: # Replace 'train' with the correct split if necessary
12
- cityOrState=item['cityOrState']
13
- link=item['link']
14
- linkType=item['linkType']
15
- links_html += f"<li><a href='{link}' target='_blank'>{cityOrState} - {linkType}</a></li>"
16
- links_html += "</ul>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  # Use Streamlit components to render the HTML
19
- components.html(links_html)
 
5
  # Load the dataset
6
  dataset = load_dataset("awacke1/DatasetOfDatasetsUSA")
7
 
8
+ # Initialize session state for record navigation
9
+ if 'index' not in st.session_state:
10
+ st.session_state.index = 0
11
+
12
+ # Define the maximum index as the length of the dataset - 1
13
+ max_index = len(dataset['train']) - 1
14
+
15
+ # Navigation buttons
16
+ col1, col2, col3, col4, col5 = st.columns(5)
17
+ with col1:
18
+ if st.button('โฎ๏ธ'):
19
+ st.session_state.index = 0
20
+ with col2:
21
+ if st.button('โ—€๏ธ') and st.session_state.index > 0:
22
+ st.session_state.index -= 1
23
+ with col3:
24
+ st.write(f"Record {st.session_state.index + 1} of {max_index + 1}")
25
+ with col4:
26
+ if st.button('โ–ถ๏ธ') and st.session_state.index < max_index:
27
+ st.session_state.index += 1
28
+ with col5:
29
+ if st.button('โญ๏ธ'):
30
+ st.session_state.index = max_index
31
+
32
+ # Assuming the dataset has the columns 'cityOrState', 'link', and 'linkType'
33
+ item = dataset['train'][st.session_state.index]
34
+ cityOrState = item['cityOrState']
35
+ link = item['link']
36
+ linkType = item['linkType']
37
+
38
+ # Build the HTML for the current record
39
+ links_html = f"""
40
+ <ul style="list-style: none; padding: 0;">
41
+ <li style="margin: 10px 0; padding: 10px; background-color: #f0f0f0; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
42
+ <a href="{link}" target="_blank" style="text-decoration: none; color: #333;">
43
+ <strong>{cityOrState}</strong> - {linkType} ๐Ÿ”—
44
+ </a>
45
+ </li>
46
+ </ul>
47
+ """
48
 
49
  # Use Streamlit components to render the HTML
50
+ components.html(links_html, height=100)