Spaces:
Sleeping
Sleeping
app updated
Browse files
app.py
CHANGED
|
@@ -40,6 +40,12 @@ def form_dialog():
|
|
| 40 |
st.session_state.data = data
|
| 41 |
st.rerun()
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Initialize session state
|
| 44 |
if 'form_submitted' not in st.session_state:
|
| 45 |
st.session_state.form_submitted = False
|
|
@@ -110,38 +116,10 @@ else:
|
|
| 110 |
if len(shelters) == 0:
|
| 111 |
st.warning("No shelters found matching your criteria.")
|
| 112 |
else:
|
| 113 |
-
# Debug print to see the structure of the first shelter
|
| 114 |
-
# st.write("Shelter structure:", shelters[0])
|
| 115 |
-
|
| 116 |
# Create two columns
|
| 117 |
col1, col2 = st.columns([1, 2])
|
| 118 |
|
| 119 |
with col1:
|
| 120 |
-
# Custom HTML for buttons
|
| 121 |
-
# st.markdown("""
|
| 122 |
-
# <style>
|
| 123 |
-
# .button-container {
|
| 124 |
-
# display: flex;
|
| 125 |
-
# flex-direction: column;
|
| 126 |
-
# align-items: center;
|
| 127 |
-
# gap: 20px;
|
| 128 |
-
# width: 100%;
|
| 129 |
-
# }
|
| 130 |
-
# .stButton button {
|
| 131 |
-
# background-color: #4CAF50;
|
| 132 |
-
# color: white;
|
| 133 |
-
# padding: 10px 20px;
|
| 134 |
-
# border: none;
|
| 135 |
-
# cursor: pointer;
|
| 136 |
-
# font-size: 16px;
|
| 137 |
-
# }
|
| 138 |
-
# </style>
|
| 139 |
-
# <div class="button-container">
|
| 140 |
-
# <button onclick="document.querySelector('button[aria-label=Previous]').click()">Previous</button>
|
| 141 |
-
# <button onclick="document.querySelector('button[aria-label=Next]').click()">Next</button>
|
| 142 |
-
# </div>
|
| 143 |
-
# """, unsafe_allow_html=True)
|
| 144 |
-
|
| 145 |
if st.button("Previous", key="previous"):
|
| 146 |
if st.session_state.shelter_index > 0:
|
| 147 |
st.session_state.shelter_index -= 1
|
|
@@ -152,11 +130,12 @@ else:
|
|
| 152 |
st.session_state.shelter_index += 1
|
| 153 |
st.experimental_rerun()
|
| 154 |
|
|
|
|
|
|
|
|
|
|
| 155 |
with col2:
|
| 156 |
# Display the current shelter information
|
| 157 |
shelter = shelters[st.session_state.shelter_index]
|
| 158 |
-
some_random_name = f'### {shelter["description"]}'
|
| 159 |
-
st.markdown(some_random_name)
|
| 160 |
st.write(shelter["description"])
|
| 161 |
st.header(shelter["header"])
|
| 162 |
st.image(shelter["image_url"])
|
|
|
|
| 40 |
st.session_state.data = data
|
| 41 |
st.rerun()
|
| 42 |
|
| 43 |
+
# Function to reset session state
|
| 44 |
+
def reset_session_state():
|
| 45 |
+
st.session_state.form_submitted = False
|
| 46 |
+
st.session_state.shelter_index = 0
|
| 47 |
+
st.experimental_rerun()
|
| 48 |
+
|
| 49 |
# Initialize session state
|
| 50 |
if 'form_submitted' not in st.session_state:
|
| 51 |
st.session_state.form_submitted = False
|
|
|
|
| 116 |
if len(shelters) == 0:
|
| 117 |
st.warning("No shelters found matching your criteria.")
|
| 118 |
else:
|
|
|
|
|
|
|
|
|
|
| 119 |
# Create two columns
|
| 120 |
col1, col2 = st.columns([1, 2])
|
| 121 |
|
| 122 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
if st.button("Previous", key="previous"):
|
| 124 |
if st.session_state.shelter_index > 0:
|
| 125 |
st.session_state.shelter_index -= 1
|
|
|
|
| 130 |
st.session_state.shelter_index += 1
|
| 131 |
st.experimental_rerun()
|
| 132 |
|
| 133 |
+
if st.button("Resubmit", key="resubmit"):
|
| 134 |
+
reset_session_state()
|
| 135 |
+
|
| 136 |
with col2:
|
| 137 |
# Display the current shelter information
|
| 138 |
shelter = shelters[st.session_state.shelter_index]
|
|
|
|
|
|
|
| 139 |
st.write(shelter["description"])
|
| 140 |
st.header(shelter["header"])
|
| 141 |
st.image(shelter["image_url"])
|