import streamlit as st import os import random from generate_jokes import generate_inside_jokes, generate_motivation # Page Config st.set_page_config( page_title="Memory Forever", page_icon="💛", layout="wide" ) # Custom CSS st.markdown(""" """, unsafe_allow_html=True) # Header st.title("💛 Memory Forever 👩‍✈️") st.markdown("---") # Layout: 2 Columns col1, col2 = st.columns([1, 2]) with col1: st.header("📸 Past Gallery") # Load images from 'sarah' directory image_dir = "sarah" if os.path.exists(image_dir): images = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))] if images: # Display a random image or a grid selected_image = random.choice(images) st.image(os.path.join(image_dir, selected_image), caption="Classic Sarah Moment", use_container_width=True) # Optional: Show more images in an expander with st.expander("See more photos"): for img in images: st.image(os.path.join(image_dir, img), use_container_width=True) else: st.info("No images found in 'sarah' folder. Add some photos to see them here!") else: st.warning("Folder 'sarah' not found. Please create it and add images.") st.markdown("---") st.subheader("⚙️ Settings") count = st.slider("How many jokes?", 1, 10, 3) st.markdown("---") st.subheader("💪 Daily Boost") if st.button("Need a quick motivation ✨"): with st.spinner("Finding the right words..."): motivation = generate_motivation() st.markdown(f'
{motivation}
', unsafe_allow_html=True) with col2: st.header("✨ Memory jokes fusion") if st.button("Generate 🎲"): with st.spinner("Cooking up some humor..."): try: jokes_text = generate_inside_jokes(count) # Parse the output to separate jokes and memory if "MEMORY FOR SARAH:" in jokes_text: parts = jokes_text.split("MEMORY FOR SARAH:") jokes_section = parts[0].replace("INSIDE JOKES:", "").strip() memory_section = parts[1].strip().strip('"') else: jokes_section = jokes_text memory_section = "Remember that time..." # Display Jokes st.markdown("### 🎭 Inside Jokes") for line in jokes_section.split('\n'): if line.strip(): st.markdown(f'
{line.strip()}
', unsafe_allow_html=True) # Display Memory st.markdown("### 💌 A Memory to Cherish") st.markdown(f'
"{memory_section}"
', unsafe_allow_html=True) except Exception as e: st.error(f"Oof! Something went wrong: {e}") # Footer st.markdown("---") st.markdown("
Made with 💖 by Aman
", unsafe_allow_html=True)