Spaces:
Sleeping
Sleeping
File size: 5,911 Bytes
c66bbb5 9570bb3 c66bbb5 9d4e274 c66bbb5 9570bb3 c66bbb5 9570bb3 c66bbb5 9570bb3 c66bbb5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
import streamlit as st
import os
import random
from generate_jokes import generate_inside_jokes, generate_motivation
from generate_quote_card import create_quote_card
# Page Config
st.set_page_config(
page_title="Memory Forever",
page_icon="π",
layout="wide"
)
# Custom CSS
st.markdown("""
<style>
.main {
background-color: #f0f2f6;
}
.stButton>button {
width: 100%;
background-color: #ff4b4b;
color: white;
border-radius: 10px;
height: 50px;
font-size: 20px;
}
.joke-card {
background-color: white;
color: black;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
margin-bottom: 15px;
border-left: 5px solid #ff4b4b;
}
.memory-card {
background-color: #fff3cd;
padding: 15px;
border-radius: 10px;
border: 1px solid #ffeeba;
color: #856404;
font-style: italic;
}
.motivation-card {
background-color: #d4edda;
color: #155724;
padding: 20px;
border-radius: 10px;
border-left: 5px solid #28a745;
margin-top: 20px;
font-weight: bold;
}
h1 {
color: #ff4b4b;
text-align: center;
font-family: 'Helvetica', sans-serif;
}
</style>
""", 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 = "src/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'<div class="motivation-card">{motivation}</div>', unsafe_allow_html=True)
# Download button for motivation
card_buffer = create_quote_card(motivation, card_type="motivation", title="Daily Motivation")
st.download_button(
label="π₯ Download Card",
data=card_buffer,
file_name="motivation_card.png",
mime="image/png",
key="download_motivation"
)
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")
jokes_list = [line.strip() for line in jokes_section.split('\n') if line.strip()]
for idx, joke in enumerate(jokes_list):
col_joke, col_download = st.columns([4, 1])
with col_joke:
st.markdown(f'<div class="joke-card">{joke}</div>', unsafe_allow_html=True)
with col_download:
card_buffer = create_quote_card(joke, card_type="joke", title="Inside Joke")
st.download_button(
label="π₯",
data=card_buffer,
file_name=f"joke_card_{idx+1}.png",
mime="image/png",
key=f"download_joke_{idx}"
)
# Display Memory
st.markdown("### π A Memory to Cherish")
col_mem, col_mem_download = st.columns([4, 1])
with col_mem:
st.markdown(f'<div class="memory-card">"{memory_section}"</div>', unsafe_allow_html=True)
with col_mem_download:
mem_card_buffer = create_quote_card(memory_section, card_type="memory", title="A Memory")
st.download_button(
label="π₯",
data=mem_card_buffer,
file_name="memory_card.png",
mime="image/png",
key="download_memory"
)
except Exception as e:
st.error(f"Oof! Something went wrong: {e}")
# Footer
st.markdown("---")
st.markdown("<div style='text-align: center; color: gray;'>Made with π by Aman</div>", unsafe_allow_html=True)
|