Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64 # For image encoding
|
| 3 |
+
|
| 4 |
+
# Password check (basic - improve for production)
|
| 5 |
+
def check_password():
|
| 6 |
+
entered_password = st.text_input("Enter Password:")
|
| 7 |
+
if entered_password == st.secrets["APP_PASSWORD"]: # Access password from secrets
|
| 8 |
+
st.session_state.password_correct = True
|
| 9 |
+
else:
|
| 10 |
+
st.session_state.password_correct = False
|
| 11 |
+
|
| 12 |
+
# Function to encode images to base64
|
| 13 |
+
def encode_image(image_path):
|
| 14 |
+
with open(image_path, "rb") as image_file:
|
| 15 |
+
encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
|
| 16 |
+
return f"data:image/jpeg;base64,{encoded_string}" # Adjust image type if needed
|
| 17 |
+
|
| 18 |
+
# Example content (replace with your personalized content)
|
| 19 |
+
def display_content():
|
| 20 |
+
st.title("Happy Valentine's Day, My Love!")
|
| 21 |
+
|
| 22 |
+
# Example: Displaying an image
|
| 23 |
+
st.image(encode_image("path/to/your/image.jpg"), use_column_width=True) # Replace with your image path
|
| 24 |
+
|
| 25 |
+
st.write("A custom message or poem goes here...")
|
| 26 |
+
|
| 27 |
+
# ... (Add more personalized content sections)
|
| 28 |
+
|
| 29 |
+
# Initialize password state
|
| 30 |
+
if "password_correct" not in st.session_state:
|
| 31 |
+
st.session_state.password_correct = False
|
| 32 |
+
|
| 33 |
+
if not st.session_state.password_correct:
|
| 34 |
+
check_password()
|
| 35 |
+
else:
|
| 36 |
+
display_content()
|
| 37 |
+
|
| 38 |
+
if not st.session_state.password_correct and st.text_input("Enter Password:"):
|
| 39 |
+
st.error("Incorrect password.")
|