Spaces:
Sleeping
Sleeping
Create backup1.app.py
Browse files- backup1.app.py +50 -0
backup1.app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from datasets import load_dataset
|
3 |
+
import streamlit.components.v1 as components
|
4 |
+
|
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)
|