ak0601 commited on
Commit
9570bb3
Β·
verified Β·
1 Parent(s): 3470868

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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 = "src/sarah"
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
- if line.strip():
122
- st.markdown(f'<div class="joke-card">{line.strip()}</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  # Display Memory
125
  st.markdown("### πŸ’Œ A Memory to Cherish")
126
- st.markdown(f'<div class="memory-card">"{memory_section}"</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
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}")