Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +39 -5
src/streamlit_app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import os
|
| 3 |
import random
|
| 4 |
from generate_jokes import generate_inside_jokes, generate_motivation
|
|
|
|
| 5 |
|
| 6 |
# Page Config
|
| 7 |
st.set_page_config(
|
|
@@ -69,7 +70,7 @@ with col1:
|
|
| 69 |
st.header("πΈ Past Gallery")
|
| 70 |
|
| 71 |
# Load images from 'sarah' directory
|
| 72 |
-
image_dir = "
|
| 73 |
if os.path.exists(image_dir):
|
| 74 |
images = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))]
|
| 75 |
|
|
@@ -97,6 +98,16 @@ with col1:
|
|
| 97 |
with st.spinner("Finding the right words..."):
|
| 98 |
motivation = generate_motivation()
|
| 99 |
st.markdown(f'<div class="motivation-card">{motivation}</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
with col2:
|
| 102 |
st.header("β¨ Memory jokes fusion")
|
|
@@ -117,13 +128,36 @@ with col2:
|
|
| 117 |
|
| 118 |
# Display Jokes
|
| 119 |
st.markdown("### π Inside Jokes")
|
| 120 |
-
for line in jokes_section.split('\n')
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Display Memory
|
| 125 |
st.markdown("### π A Memory to Cherish")
|
| 126 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
except Exception as e:
|
| 129 |
st.error(f"Oof! Something went wrong: {e}")
|
|
|
|
| 2 |
import os
|
| 3 |
import random
|
| 4 |
from generate_jokes import generate_inside_jokes, generate_motivation
|
| 5 |
+
from generate_quote_card import create_quote_card
|
| 6 |
|
| 7 |
# Page Config
|
| 8 |
st.set_page_config(
|
|
|
|
| 70 |
st.header("πΈ Past Gallery")
|
| 71 |
|
| 72 |
# Load images from 'sarah' directory
|
| 73 |
+
image_dir = "sarah"
|
| 74 |
if os.path.exists(image_dir):
|
| 75 |
images = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))]
|
| 76 |
|
|
|
|
| 98 |
with st.spinner("Finding the right words..."):
|
| 99 |
motivation = generate_motivation()
|
| 100 |
st.markdown(f'<div class="motivation-card">{motivation}</div>', unsafe_allow_html=True)
|
| 101 |
+
|
| 102 |
+
# Download button for motivation
|
| 103 |
+
card_buffer = create_quote_card(motivation, card_type="motivation", title="Daily Motivation")
|
| 104 |
+
st.download_button(
|
| 105 |
+
label="π₯ Download Card",
|
| 106 |
+
data=card_buffer,
|
| 107 |
+
file_name="motivation_card.png",
|
| 108 |
+
mime="image/png",
|
| 109 |
+
key="download_motivation"
|
| 110 |
+
)
|
| 111 |
|
| 112 |
with col2:
|
| 113 |
st.header("β¨ Memory jokes fusion")
|
|
|
|
| 128 |
|
| 129 |
# Display Jokes
|
| 130 |
st.markdown("### π Inside Jokes")
|
| 131 |
+
jokes_list = [line.strip() for line in jokes_section.split('\n') if line.strip()]
|
| 132 |
+
|
| 133 |
+
for idx, joke in enumerate(jokes_list):
|
| 134 |
+
col_joke, col_download = st.columns([4, 1])
|
| 135 |
+
with col_joke:
|
| 136 |
+
st.markdown(f'<div class="joke-card">{joke}</div>', unsafe_allow_html=True)
|
| 137 |
+
with col_download:
|
| 138 |
+
card_buffer = create_quote_card(joke, card_type="joke", title="Inside Joke")
|
| 139 |
+
st.download_button(
|
| 140 |
+
label="π₯",
|
| 141 |
+
data=card_buffer,
|
| 142 |
+
file_name=f"joke_card_{idx+1}.png",
|
| 143 |
+
mime="image/png",
|
| 144 |
+
key=f"download_joke_{idx}"
|
| 145 |
+
)
|
| 146 |
|
| 147 |
# Display Memory
|
| 148 |
st.markdown("### π A Memory to Cherish")
|
| 149 |
+
col_mem, col_mem_download = st.columns([4, 1])
|
| 150 |
+
with col_mem:
|
| 151 |
+
st.markdown(f'<div class="memory-card">"{memory_section}"</div>', unsafe_allow_html=True)
|
| 152 |
+
with col_mem_download:
|
| 153 |
+
mem_card_buffer = create_quote_card(memory_section, card_type="memory", title="A Memory")
|
| 154 |
+
st.download_button(
|
| 155 |
+
label="π₯",
|
| 156 |
+
data=mem_card_buffer,
|
| 157 |
+
file_name="memory_card.png",
|
| 158 |
+
mime="image/png",
|
| 159 |
+
key="download_memory"
|
| 160 |
+
)
|
| 161 |
|
| 162 |
except Exception as e:
|
| 163 |
st.error(f"Oof! Something went wrong: {e}")
|