Update app.py
Browse files
app.py
CHANGED
|
@@ -2,32 +2,46 @@ import streamlit as st
|
|
| 2 |
from PIL import Image
|
| 3 |
import os
|
| 4 |
import io
|
|
|
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Valentine's Day Surprise", page_icon="❤️", layout="wide")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
if
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
st.session_state.password_entered = False
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
correct_password = "yoursecretword" # Replace with your secret word
|
| 25 |
|
| 26 |
if password_entered == correct_password:
|
| 27 |
st.session_state.password_entered = True
|
| 28 |
st.rerun()
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
st.title("Happy Valentine's Day, My Love! ❤️")
|
| 32 |
|
| 33 |
# --- Styling ---
|
|
@@ -119,42 +133,49 @@ if st.session_state.password_entered:
|
|
| 119 |
)
|
| 120 |
|
| 121 |
# Tabs
|
| 122 |
-
tabs = ["
|
| 123 |
selected_tab = st.sidebar.radio("Select a tab:", tabs)
|
| 124 |
|
| 125 |
-
if selected_tab == "
|
| 126 |
-
st.write("##
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
st.warning(f"Could not load previously saved image: {image_name}. It might have been deleted.")
|
| 156 |
-
except Exception as e:
|
| 157 |
-
st.error(f"Error loading previously saved image {image_name}: {e}")
|
| 158 |
|
| 159 |
elif selected_tab == "Messages":
|
| 160 |
st.write("## Sweet Messages")
|
|
@@ -183,23 +204,4 @@ if st.session_state.password_entered:
|
|
| 183 |
elif selected_tab == "Reasons":
|
| 184 |
st.write("## Reasons I Love You")
|
| 185 |
|
| 186 |
-
if
|
| 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.rerun()
|
| 197 |
-
|
| 198 |
-
new_reason = st.text_input("Add a reason:")
|
| 199 |
-
if st.button("Save Reason"):
|
| 200 |
-
if new_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!")
|
| 205 |
-
st.rer
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import os
|
| 4 |
import io
|
| 5 |
+
import random
|
| 6 |
|
| 7 |
st.set_page_config(page_title="Valentine's Day Surprise", page_icon="❤️", layout="wide")
|
| 8 |
|
| 9 |
+
# --- Startup Page ---
|
| 10 |
+
if not st.session_state.get('password_entered', False):
|
| 11 |
+
st.markdown(
|
| 12 |
+
"""
|
| 13 |
+
<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh;">
|
| 14 |
+
<img src="YOUR_GIF_URL_HERE" width="200" style="margin-bottom: 20px;">
|
| 15 |
+
<h1 style="color: #f08080; font-family: 'Arial', sans-serif;">Happy Valentine's Day!</h1>
|
| 16 |
+
<p style="font-size: 1.2em; margin-bottom: 30px;">Enter the secret word to unlock the surprise:</p>
|
| 17 |
+
</div>
|
| 18 |
+
""",
|
| 19 |
+
unsafe_allow_html=True,
|
| 20 |
+
)
|
|
|
|
| 21 |
|
| 22 |
+
password_entered = st.text_input("", type="password", placeholder="Enter the secret word")
|
| 23 |
+
correct_password = "anna" # Replace with your secret word
|
|
|
|
| 24 |
|
| 25 |
if password_entered == correct_password:
|
| 26 |
st.session_state.password_entered = True
|
| 27 |
st.rerun()
|
| 28 |
|
| 29 |
+
elif password_entered:
|
| 30 |
+
st.error("Incorrect secret word. Try again.")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# --- Main Content (after password entered) ---
|
| 34 |
+
if st.session_state.get('password_entered', False):
|
| 35 |
+
# Load previous data (if it exists)
|
| 36 |
+
if os.path.exists("data.txt"):
|
| 37 |
+
with open("data.txt", "r") as f:
|
| 38 |
+
try:
|
| 39 |
+
saved_data = eval(f.read())
|
| 40 |
+
except:
|
| 41 |
+
saved_data = {"messages": [], "reasons": [], "compliments": []}
|
| 42 |
+
else:
|
| 43 |
+
saved_data = {"messages": [], "reasons": [], "compliments": []}
|
| 44 |
+
|
| 45 |
st.title("Happy Valentine's Day, My Love! ❤️")
|
| 46 |
|
| 47 |
# --- Styling ---
|
|
|
|
| 133 |
)
|
| 134 |
|
| 135 |
# Tabs
|
| 136 |
+
tabs = ["Compliments", "Messages", "Reasons"]
|
| 137 |
selected_tab = st.sidebar.radio("Select a tab:", tabs)
|
| 138 |
|
| 139 |
+
if selected_tab == "Compliments":
|
| 140 |
+
st.write("## Sweet Compliments")
|
| 141 |
+
|
| 142 |
+
compliments = [
|
| 143 |
+
"You have the most beautiful smile.",
|
| 144 |
+
"Your kindness is inspiring.",
|
| 145 |
+
"You’re incredibly intelligent and witty.",
|
| 146 |
+
"You make every day an adventure.",
|
| 147 |
+
"Your laugh is contagious and makes me so happy.",
|
| 148 |
+
"You have a heart of gold.",
|
| 149 |
+
"You’re the most supportive person I know.",
|
| 150 |
+
"You have amazing taste in everything.",
|
| 151 |
+
"You’re my best friend and my soulmate.",
|
| 152 |
+
"You’re simply amazing!"
|
| 153 |
+
]
|
| 154 |
+
|
| 155 |
+
if saved_data["compliments"]:
|
| 156 |
+
for i, compliment in enumerate(saved_data["compliments"]):
|
| 157 |
+
col1, col2 = st.columns([0.8, 0.2])
|
| 158 |
+
with col1:
|
| 159 |
+
st.write(f"{i+1}. {compliment}")
|
| 160 |
+
with col2:
|
| 161 |
+
if st.button("Delete", key=f"delete_compliment_{i}"):
|
| 162 |
+
del saved_data["compliments"][i]
|
| 163 |
+
with open("data.txt", "w") as f:
|
| 164 |
+
f.write(str(saved_data))
|
| 165 |
+
st.rerun()
|
| 166 |
|
| 167 |
+
if st.button("Generate Random Compliment"):
|
| 168 |
+
random_compliment = random.choice(compliments)
|
| 169 |
+
st.write(f"💖 {random_compliment}")
|
| 170 |
|
| 171 |
+
new_compliment = st.text_area("Add a new compliment:", height=50)
|
| 172 |
+
if st.button("Save Compliment"):
|
| 173 |
+
if new_compliment:
|
| 174 |
+
saved_data["compliments"].append(new_compliment)
|
| 175 |
+
with open("data.txt", "w") as f:
|
| 176 |
+
f.write(str(saved_data))
|
| 177 |
+
st.success("Compliment saved!")
|
| 178 |
+
st.rerun()
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
elif selected_tab == "Messages":
|
| 181 |
st.write("## Sweet Messages")
|
|
|
|
| 204 |
elif selected_tab == "Reasons":
|
| 205 |
st.write("## Reasons I Love You")
|
| 206 |
|
| 207 |
+
if saved
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|