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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -5
app.py CHANGED
@@ -1,8 +1,9 @@
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="❤️")
6
 
7
  # Load previous data (if it exists)
8
  if os.path.exists("data.txt"):
@@ -21,6 +22,91 @@ password_entered = st.text_input("Enter the secret word:", type="password")
21
  correct_password = "anna" # Replace with your secret word
22
 
23
  if password_entered == correct_password:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # Tabs
25
  tabs = ["Memories", "Messages", "Reasons"]
26
  selected_tab = st.sidebar.radio("Select a tab:", tabs)
@@ -48,11 +134,12 @@ if password_entered == correct_password:
48
  except Exception as e:
49
  st.error(f"Error opening image {uploaded_file.name}: {e}")
50
 
51
- elif saved_data["images"]: # Show previously uploaded images
 
52
  for image_name in saved_data["images"]:
53
  try:
54
- image_path = os.path.join("static", image_name) # Correct path!
55
- image = Image.open(image_path) # Open from correct path
56
  st.image(image, caption=image_name, use_column_width=True)
57
  except FileNotFoundError:
58
  st.warning(f"Could not load previously saved image: {image_name}. It might have been deleted.")
@@ -70,7 +157,7 @@ if password_entered == correct_password:
70
  st.success("Message saved!")
71
  st.rerun()
72
 
73
- if saved_data["messages"]: # Display previously saved messages
74
  for message in saved_data["messages"]:
75
  st.write(f"- {message}")
76
 
 
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
 
8
  # Load previous data (if it exists)
9
  if os.path.exists("data.txt"):
 
22
  correct_password = "anna" # Replace with your secret word
23
 
24
  if password_entered == correct_password:
25
+ # --- Styling ---
26
+ st.markdown(
27
+ """
28
+ <style>
29
+ body {
30
+ background-color: #f8f0e3; /* Light beige */
31
+ font-family: 'Arial', sans-serif;
32
+ }
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 */
39
+ border-radius: 5px;
40
+ }
41
+ </style>
42
+ """,
43
+ unsafe_allow_html=True,
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"]
112
  selected_tab = st.sidebar.radio("Select a tab:", tabs)
 
134
  except Exception as e:
135
  st.error(f"Error opening image {uploaded_file.name}: {e}")
136
 
137
+ # Display previously uploaded images (always)
138
+ if saved_data["images"]:
139
  for image_name in saved_data["images"]:
140
  try:
141
+ image_path = os.path.join("static", image_name)
142
+ image = Image.open(image_path)
143
  st.image(image, caption=image_name, use_column_width=True)
144
  except FileNotFoundError:
145
  st.warning(f"Could not load previously saved image: {image_name}. It might have been deleted.")
 
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