diff --git a/Days of Love/app.py b/Days of Love/app.py new file mode 100644 index 0000000..31009bc --- /dev/null +++ b/Days of Love/app.py @@ -0,0 +1,134 @@ +import streamlit as st +from datetime import date +from PIL import Image +import base64 + +st.set_page_config( + page_title="How Long Have We Loved?", + page_icon="💖", + layout="wide" +) + +st.title("💖 How Long Have We Loved? 💖") +st.markdown("Enter the date your love story began, and we'll calculate your beautiful journey in days!") +st.markdown("---") + +input_col, display_col = st.columns([1, 1]) + +with input_col: + st.header("Your Love Story Details") + loved_one_name = st.text_input( + label="What's your loved one's name?", + placeholder="e.g., Alex, Sofia, My Honey", + max_chars=50, + key="loved_one_name" + ) + + start_date = st.date_input( + label="When did your love story begin?", + value=date.today(), + max_value=date.today(), + key="start_date" + ) + + calculate_button = st.button("Calculate Our Love Days!", key="calculate_button", type="primary") + +with display_col: + st.header("Your Love Milestone!") + results_placeholder = st.empty() + +if calculate_button: + with results_placeholder.container(): + if not loved_one_name: + st.error("Please enter your loved one's name!") + elif start_date >= date.today(): + st.error("The start date must be in the past! 😉") + else: + today = date.today() + time_difference = today - start_date + total_days = time_difference.days + + try: + years = today.year - start_date.year + months = today.month - start_date.month + if months < 0: + years -= 1 + months += 12 + except: + years = int(total_days / 365.25) + months = None + + st.subheader(f"Congratulations, {loved_one_name}!") + st.balloons() + + main_message = f"We have been in love for {total_days:,} days!" + + styled_message = f""" +