Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -153,6 +153,10 @@ if submit_ad:
|
|
153 |
if not isinstance(generated_ad, str):
|
154 |
st.error("Error al generar el anuncio")
|
155 |
else:
|
|
|
|
|
|
|
|
|
156 |
st.markdown(f"""
|
157 |
<div style="{styles['results_container']}">
|
158 |
<h3>Anuncio Generado:</h3>
|
@@ -163,15 +167,43 @@ if submit_ad:
|
|
163 |
# Aplicar estilo para el bot贸n de descarga
|
164 |
st.markdown(styles["download_button"], unsafe_allow_html=True)
|
165 |
|
166 |
-
#
|
|
|
|
|
|
|
|
|
167 |
st.download_button(
|
168 |
label="Descargar Anuncio",
|
169 |
data=generated_ad,
|
170 |
-
file_name="
|
171 |
mime="text/plain"
|
172 |
)
|
173 |
else:
|
174 |
col2.warning("Por favor, completa todos los campos antes de generar el anuncio.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
# Agregar firma del autor al final de la p谩gina
|
177 |
st.markdown('---')
|
|
|
153 |
if not isinstance(generated_ad, str):
|
154 |
st.error("Error al generar el anuncio")
|
155 |
else:
|
156 |
+
# Store the generated ad in session state to preserve it
|
157 |
+
st.session_state.current_ad = generated_ad
|
158 |
+
|
159 |
+
# Display the ad
|
160 |
st.markdown(f"""
|
161 |
<div style="{styles['results_container']}">
|
162 |
<h3>Anuncio Generado:</h3>
|
|
|
167 |
# Aplicar estilo para el bot贸n de descarga
|
168 |
st.markdown(styles["download_button"], unsafe_allow_html=True)
|
169 |
|
170 |
+
# Get current timestamp for the filename
|
171 |
+
import datetime
|
172 |
+
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
173 |
+
|
174 |
+
# Bot贸n de descarga with timestamp in filename
|
175 |
st.download_button(
|
176 |
label="Descargar Anuncio",
|
177 |
data=generated_ad,
|
178 |
+
file_name=f"anuncio_facebook_{timestamp}.txt",
|
179 |
mime="text/plain"
|
180 |
)
|
181 |
else:
|
182 |
col2.warning("Por favor, completa todos los campos antes de generar el anuncio.")
|
183 |
+
# If there's a stored ad but no new submission, display it
|
184 |
+
elif 'current_ad' in st.session_state:
|
185 |
+
with col2:
|
186 |
+
st.markdown(f"""
|
187 |
+
<div style="{styles['results_container']}">
|
188 |
+
<h3>Anuncio Generado:</h3>
|
189 |
+
<p>{st.session_state.current_ad}</p>
|
190 |
+
</div>
|
191 |
+
""", unsafe_allow_html=True)
|
192 |
+
|
193 |
+
# Aplicar estilo para el bot贸n de descarga
|
194 |
+
st.markdown(styles["download_button"], unsafe_allow_html=True)
|
195 |
+
|
196 |
+
# Get current timestamp for the filename
|
197 |
+
import datetime
|
198 |
+
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
199 |
+
|
200 |
+
# Bot贸n de descarga with timestamp in filename
|
201 |
+
st.download_button(
|
202 |
+
label="Descargar Anuncio",
|
203 |
+
data=st.session_state.current_ad,
|
204 |
+
file_name=f"anuncio_facebook_{timestamp}.txt",
|
205 |
+
mime="text/plain"
|
206 |
+
)
|
207 |
|
208 |
# Agregar firma del autor al final de la p谩gina
|
209 |
st.markdown('---')
|