jcmachicao commited on
Commit
a4e40d7
verified
1 Parent(s): 28dd8cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -59,6 +59,17 @@ def mostrar_detalles(normativa_seleccionada):
59
  html = crear_html(normativa)
60
  return html
61
 
 
 
 
 
 
 
 
 
 
 
 
62
  def cargar_desde_airtable():
63
  response = requests.get(url, headers=headers)
64
 
@@ -142,7 +153,7 @@ with iface:
142
  gr.Markdown("## Selecciona una Normativa:")
143
  normativa_dropdown = gr.Dropdown(choices=norm_options, label="Normativas")
144
  normativa_html = gr.HTML()
145
- normativa_dropdown.change(fn=mostrar_detalles, inputs=normativa_dropdown, outputs=[normativa_html, None])
146
 
147
  with gr.Row():
148
  gr.Markdown("## Red de Aportes:")
 
59
  html = crear_html(normativa)
60
  return html
61
 
62
+
63
+ def mostrar_detalles(normativa_seleccionada):
64
+ if not normativa_seleccionada:
65
+ return "<p>Por favor selecciona una normativa</p>", ""
66
+ normativas = cargar_normativas()
67
+ id_normativa = normativa_seleccionada # Extract the norm name
68
+ for normativa in normativas["normativa_peruana_gestion_riesgos"]:
69
+ if id_normativa == normativa['nombre']:
70
+ return crear_html(normativa), normativa["nombre"] # Return both HTML and name
71
+ return "<p>No se encontr贸 la normativa</p>", ""
72
+
73
  def cargar_desde_airtable():
74
  response = requests.get(url, headers=headers)
75
 
 
153
  gr.Markdown("## Selecciona una Normativa:")
154
  normativa_dropdown = gr.Dropdown(choices=norm_options, label="Normativas")
155
  normativa_html = gr.HTML()
156
+ normativa_dropdown.change(fn=mostrar_detalles, inputs=normativa_dropdown, outputs=[normativa_html, norma_field])
157
 
158
  with gr.Row():
159
  gr.Markdown("## Red de Aportes:")