Mavhas commited on
Commit
ddfdfe5
·
verified ·
1 Parent(s): e70422e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -102
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import streamlit as st
2
  from PIL import Image
3
  import os
4
- import random
5
 
6
  st.set_page_config(page_title="Valentine's Day Surprise", page_icon="❤️", layout="wide")
7
 
@@ -15,13 +14,21 @@ if os.path.exists("data.txt"):
15
  else:
16
  saved_data = {"messages": [], "reasons": [], "images": []}
17
 
18
- st.title("Happy Valentine's Day, My Love! ❤️")
19
-
20
  # Password logic (for simulation only - NOT secure)
21
- password_entered = st.text_input("Enter the secret word:", type="password")
22
- correct_password = "anna" # Replace with your secret word
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- if password_entered == correct_password:
25
  # --- Styling ---
26
  st.markdown(
27
  """
@@ -33,6 +40,9 @@ if password_entered == correct_password:
33
  .stButton>button {
34
  background-color: #f08080 !important; /* Light coral */
35
  color: white !important;
 
 
 
36
  }
37
  .stTextInput, .stTextArea, .stSelectbox {
38
  border: 2px solid #f08080; /* Light coral */
@@ -44,68 +54,7 @@ if password_entered == correct_password:
44
  )
45
 
46
  # --- Heart Animation (using HTML and CSS) ---
47
- st.markdown(
48
- """
49
- <div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;">
50
- <div class="heart"></div>
51
- <div class="heart" style="left: 10%; animation-delay: 2s;"></div>
52
- <div class="heart" style="left: 20%; animation-delay: 1s;"></div>
53
- <div class="heart" style="left: 30%; animation-delay: 3s;"></div>
54
- <div class="heart" style="left: 40%; animation-delay: 0.5s;"></div>
55
- <div class="heart" style="left: 50%; animation-delay: 2.5s;"></div>
56
- <div class="heart" style="left: 60%; animation-delay: 1.5s;"></div>
57
- <div class="heart" style="left: 70%; animation-delay: 3.5s;"></div>
58
- <div class="heart" style="left: 80%; animation-delay: 0.8s;"></div>
59
- <div class="heart" style="left: 90%; animation-delay: 2.2s;"></div>
60
- </div>
61
-
62
- <style>
63
- .heart {
64
- position: absolute;
65
- width: 30px;
66
- height: 30px;
67
- background-color: #f08080; /* Light coral */
68
- transform: rotate(-45deg);
69
- animation: heartAnimation 5s linear infinite;
70
- }
71
-
72
- .heart::before,
73
- .heart::after {
74
- content: "";
75
- position: absolute;
76
- width: 30px;
77
- height: 30px;
78
- border-radius: 50%;
79
- background-color: #f08080; /* Light coral */
80
- }
81
-
82
- .heart::before {
83
- top: -15px;
84
- left: 0;
85
- }
86
-
87
- .heart::after {
88
- top: 0;
89
- left: 15px;
90
- }
91
-
92
- @keyframes heartAnimation {
93
- 0% {
94
- top: -50px;
95
- opacity: 0;
96
- }
97
- 50% {
98
- opacity: 1;
99
- }
100
- 100% {
101
- top: 100vh;
102
- opacity: 0;
103
- }
104
- }
105
- </style>
106
- """,
107
- unsafe_allow_html=True,
108
- )
109
 
110
  # Tabs
111
  tabs = ["Memories", "Messages", "Reasons"]
@@ -120,7 +69,7 @@ if password_entered == correct_password:
120
  for uploaded_file in uploaded_files:
121
  try:
122
  image = Image.open(uploaded_file)
123
- st.image(image, caption=uploaded_file.name, use_container_width=True)
124
 
125
  # Save image to static folder and update data.txt
126
  image_path = os.path.join("static", uploaded_file.name)
@@ -147,38 +96,7 @@ if password_entered == correct_password:
147
  st.error(f"Error loading previously saved image {image_name}: {e}")
148
 
149
  elif selected_tab == "Messages":
150
- st.write("## Sweet Messages")
151
- new_message = st.text_area("Add a new message:", height=100)
152
- if st.button("Save Message"):
153
- if new_message:
154
- saved_data["messages"].append(new_message)
155
- with open("data.txt", "w") as f:
156
- f.write(str(saved_data))
157
- st.success("Message saved!")
158
- st.rerun()
159
-
160
- if saved_data["messages"]:
161
- for message in saved_data["messages"]:
162
- st.write(f"- {message}")
163
 
164
  elif selected_tab == "Reasons":
165
- st.write("## Reasons I Love You")
166
-
167
- if saved_data["reasons"]:
168
- for reason in saved_data["reasons"]:
169
- st.write(f"- {reason}")
170
-
171
- new_reason = st.text_input("Add a reason:")
172
- if st.button("Save Reason"):
173
- if new_reason:
174
- saved_data["reasons"].append(new_reason)
175
- with open("data.txt", "w") as f:
176
- f.write(str(saved_data))
177
- st.success("Reason saved!")
178
- st.rerun()
179
-
180
- elif password_entered:
181
- st.error("Incorrect secret word. Try again.")
182
-
183
- else:
184
- st.info("Enter the secret word to unlock the surprises!")
 
1
  import streamlit as st
2
  from PIL import Image
3
  import os
 
4
 
5
  st.set_page_config(page_title="Valentine's Day Surprise", page_icon="❤️", layout="wide")
6
 
 
14
  else:
15
  saved_data = {"messages": [], "reasons": [], "images": []}
16
 
 
 
17
  # Password logic (for simulation only - NOT secure)
18
+ if 'password_entered' not in st.session_state:
19
+ st.session_state.password_entered = False
20
+
21
+ if not st.session_state.password_entered:
22
+ password_entered = st.text_input("Enter the secret word:", type="password")
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.experimental_rerun() # Rerun to hide password input
28
+
29
+ if st.session_state.password_entered: # Show content only after correct password
30
+ st.title("Happy Valentine's Day, My Love! ❤️")
31
 
 
32
  # --- Styling ---
33
  st.markdown(
34
  """
 
40
  .stButton>button {
41
  background-color: #f08080 !important; /* Light coral */
42
  color: white !important;
43
+ border: none;
44
+ padding: 10px 20px;
45
+ border-radius: 5px;
46
  }
47
  .stTextInput, .stTextArea, .stSelectbox {
48
  border: 2px solid #f08080; /* Light coral */
 
54
  )
55
 
56
  # --- Heart Animation (using HTML and CSS) ---
57
+ # ... (same heart animation code as before)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  # Tabs
60
  tabs = ["Memories", "Messages", "Reasons"]
 
69
  for uploaded_file in uploaded_files:
70
  try:
71
  image = Image.open(uploaded_file)
72
+ st.image(image, caption=uploaded_file.name, use_column_width=True)
73
 
74
  # Save image to static folder and update data.txt
75
  image_path = os.path.join("static", uploaded_file.name)
 
96
  st.error(f"Error loading previously saved image {image_name}: {e}")
97
 
98
  elif selected_tab == "Messages":
99
+ # ... (same as before)
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  elif selected_tab == "Reasons":
102
+ # ... (same as before)