JeCabrera commited on
Commit
95d679a
·
verified ·
1 Parent(s): 754681a

Upload 12 files

Browse files
Files changed (2) hide show
  1. app.py +31 -24
  2. styles/styles.css +3 -1
app.py CHANGED
@@ -16,6 +16,8 @@ load_dotenv()
16
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
17
 
18
  # Función auxiliar para mostrar el contenido generado y los botones de descarga
 
 
19
  def display_generated_content(col, generated_content, content_type):
20
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
21
 
@@ -51,37 +53,42 @@ def display_generated_content(col, generated_content, content_type):
51
  file_name = f"nombres_webinar_{timestamp}.txt"
52
  download_label = "DESCARGAR NOMBRES DE WEBINAR ▶▶"
53
 
54
- # Contar el número de nombres generados (aproximadamente por el número de líneas)
55
  num_names = len([line for line in generated_content.split('\n') if line.strip().startswith(('1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.', '10.', '11.', '12.', '13.', '14.', '15.'))])
56
 
57
- # Determinar si hay más de 5 nombres para mostrar los botones de descarga
58
- has_many_items = num_names > 5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  # Mostrar el contenido generado
61
  col.subheader(subheader_text)
62
  col.markdown(generated_content)
63
 
64
- # Para los nombres, usar HTML personalizado en lugar de st.download_button
65
- if has_many_items:
66
- import base64
67
-
68
- # Codificar el contenido para descarga
69
- b64 = base64.b64encode(generated_content.encode()).decode()
70
-
71
- # Crear botón de descarga personalizado con HTML y CSS
72
- custom_download_html = f"""
73
- <div class="custom-download-button names-download-button">
74
- <a href="data:text/plain;base64,{b64}" download="{file_name}" style="text-decoration:none; color:white; display:block; width:100%; text-align:center;">
75
- {download_label}
76
- </a>
77
- </div>
78
- """
79
-
80
- # Mostrar botón de descarga superior
81
- col.markdown(custom_download_html, unsafe_allow_html=True)
82
-
83
- # Mostrar botón de descarga inferior
84
- col.markdown(custom_download_html, unsafe_allow_html=True)
85
 
86
  # Implementar la función generate_and_display para reemplazar código duplicado
87
  def generate_and_display(col, generator_func, audience, product, temperature, selected_formula, content_type, **kwargs):
 
16
  genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
17
 
18
  # Función auxiliar para mostrar el contenido generado y los botones de descarga
19
+ # In the display_generated_content function, modify the names section:
20
+
21
  def display_generated_content(col, generated_content, content_type):
22
  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
23
 
 
53
  file_name = f"nombres_webinar_{timestamp}.txt"
54
  download_label = "DESCARGAR NOMBRES DE WEBINAR ▶▶"
55
 
56
+ # Contar el número de nombres generados
57
  num_names = len([line for line in generated_content.split('\n') if line.strip().startswith(('1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.', '10.', '11.', '12.', '13.', '14.', '15.'))])
58
 
59
+ # Para los nombres, usar HTML personalizado en lugar de st.download_button
60
+ import base64
61
+
62
+ # Codificar el contenido para descarga
63
+ b64 = base64.b64encode(generated_content.encode()).decode()
64
+
65
+ # Crear botón de descarga superior con clase específica
66
+ top_button_html = f"""
67
+ <div class="custom-download-button names-download-button top-button">
68
+ <a href="data:text/plain;base64,{b64}" download="{file_name}">
69
+ {download_label}
70
+ </a>
71
+ </div>
72
+ """
73
+
74
+ # Crear botón de descarga inferior con clase específica
75
+ bottom_button_html = f"""
76
+ <div class="custom-download-button names-download-button bottom-button">
77
+ <a href="data:text/plain;base64,{b64}" download="{file_name}">
78
+ {download_label}
79
+ </a>
80
+ </div>
81
+ """
82
+
83
+ # Mostrar botón de descarga superior
84
+ col.markdown(top_button_html, unsafe_allow_html=True)
85
 
86
  # Mostrar el contenido generado
87
  col.subheader(subheader_text)
88
  col.markdown(generated_content)
89
 
90
+ # Mostrar botón de descarga inferior
91
+ col.markdown(bottom_button_html, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  # Implementar la función generate_and_display para reemplazar código duplicado
94
  def generate_and_display(col, generator_func, audience, product, temperature, selected_formula, content_type, **kwargs):
styles/styles.css CHANGED
@@ -125,10 +125,11 @@ div.stDownloadButton[data-testid*="download_bottom_names"] > button:first-child:
125
  border-radius: 5px;
126
  border: 1px solid #333;
127
  text-align: center;
128
- margin: 15px auto;
129
  width: 80%;
130
  cursor: pointer;
131
  transition: all 0.3s;
 
132
  }
133
 
134
  .custom-download-button.names-download-button:hover {
@@ -145,4 +146,5 @@ div.stDownloadButton[data-testid*="download_bottom_names"] > button:first-child:
145
  width: 100%;
146
  height: 100%;
147
  font-weight: bold;
 
148
  }
 
125
  border-radius: 5px;
126
  border: 1px solid #333;
127
  text-align: center;
128
+ margin: 20px auto;
129
  width: 80%;
130
  cursor: pointer;
131
  transition: all 0.3s;
132
+ display: block;
133
  }
134
 
135
  .custom-download-button.names-download-button:hover {
 
146
  width: 100%;
147
  height: 100%;
148
  font-weight: bold;
149
+ text-decoration: none !important;
150
  }