Update app.py
Browse files
app.py
CHANGED
|
@@ -148,7 +148,7 @@ if st.session_state.password_entered:
|
|
| 148 |
for image_name in saved_data["images"]:
|
| 149 |
try:
|
| 150 |
image_path = os.path.join("static", image_name)
|
| 151 |
-
with open(image_path, "rb") as f:
|
| 152 |
image = Image.open(f)
|
| 153 |
st.image(image, caption=image_name, use_column_width=True)
|
| 154 |
except FileNotFoundError:
|
|
@@ -158,9 +158,18 @@ if st.session_state.password_entered:
|
|
| 158 |
|
| 159 |
elif selected_tab == "Messages":
|
| 160 |
st.write("## Sweet Messages")
|
|
|
|
| 161 |
if saved_data["messages"]:
|
| 162 |
for i, message in enumerate(saved_data["messages"]):
|
| 163 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
new_message = st.text_area("Add a new message:", height=100)
|
| 166 |
if st.button("Save Message"):
|
|
@@ -176,7 +185,15 @@ if st.session_state.password_entered:
|
|
| 176 |
|
| 177 |
if saved_data["reasons"]:
|
| 178 |
for i, reason in enumerate(saved_data["reasons"]):
|
| 179 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
new_reason = st.text_input("Add a reason:")
|
| 182 |
if st.button("Save Reason"):
|
|
@@ -184,11 +201,4 @@ if st.session_state.password_entered:
|
|
| 184 |
saved_data["reasons"].append(new_reason)
|
| 185 |
with open("data.txt", "w") as f:
|
| 186 |
f.write(str(saved_data))
|
| 187 |
-
st.success("Reason saved!")
|
| 188 |
-
st.rerun()
|
| 189 |
-
|
| 190 |
-
elif password_entered:
|
| 191 |
-
st.error("Incorrect secret word. Try again.")
|
| 192 |
-
|
| 193 |
-
else:
|
| 194 |
-
st.info("Enter the secret word to unlock the surprises!")
|
|
|
|
| 148 |
for image_name in saved_data["images"]:
|
| 149 |
try:
|
| 150 |
image_path = os.path.join("static", image_name)
|
| 151 |
+
with open(image_path, "rb") as f:
|
| 152 |
image = Image.open(f)
|
| 153 |
st.image(image, caption=image_name, use_column_width=True)
|
| 154 |
except FileNotFoundError:
|
|
|
|
| 158 |
|
| 159 |
elif selected_tab == "Messages":
|
| 160 |
st.write("## Sweet Messages")
|
| 161 |
+
|
| 162 |
if saved_data["messages"]:
|
| 163 |
for i, message in enumerate(saved_data["messages"]):
|
| 164 |
+
col1, col2 = st.columns([0.8, 0.2])
|
| 165 |
+
with col1:
|
| 166 |
+
st.markdown(f"<div style='background-color: #ffe6f2; padding: 10px; border-radius: 5px; margin-bottom: 10px;'>{message}</div>", unsafe_allow_html=True)
|
| 167 |
+
with col2:
|
| 168 |
+
if st.button("Delete", key=f"delete_message_{i}"):
|
| 169 |
+
del saved_data["messages"][i]
|
| 170 |
+
with open("data.txt", "w") as f:
|
| 171 |
+
f.write(str(saved_data))
|
| 172 |
+
st.experimental_rerun()
|
| 173 |
|
| 174 |
new_message = st.text_area("Add a new message:", height=100)
|
| 175 |
if st.button("Save Message"):
|
|
|
|
| 185 |
|
| 186 |
if saved_data["reasons"]:
|
| 187 |
for i, reason in enumerate(saved_data["reasons"]):
|
| 188 |
+
col1, col2 = st.columns([0.8, 0.2])
|
| 189 |
+
with col1:
|
| 190 |
+
st.write(f"{i+1}. {reason}")
|
| 191 |
+
with col2:
|
| 192 |
+
if st.button("Delete", key=f"delete_reason_{i}"):
|
| 193 |
+
del saved_data["reasons"][i]
|
| 194 |
+
with open("data.txt", "w") as f:
|
| 195 |
+
f.write(str(saved_data))
|
| 196 |
+
st.experimental_rerun()
|
| 197 |
|
| 198 |
new_reason = st.text_input("Add a reason:")
|
| 199 |
if st.button("Save Reason"):
|
|
|
|
| 201 |
saved_data["reasons"].append(new_reason)
|
| 202 |
with open("data.txt", "w") as f:
|
| 203 |
f.write(str(saved_data))
|
| 204 |
+
st.success("Reason saved!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|