Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,33 @@ AIRT_TABLEx = os.getenv("AIRT_TABLE")
|
|
13 |
# Use Directed Graph to represent relationships
|
14 |
G = nx.DiGraph() # Fix: Use DiGraph instead of Graph
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
data = {"fields": {"Nombre": nombre, "Enfoque": enfoque, "Norma": norma, "Texto_HF": texto}}
|
23 |
requests.post(url, headers=headers, json=data)
|
24 |
|
@@ -57,5 +78,4 @@ iface = gr.Interface(
|
|
57 |
inputs=["text", "text", "text", "text"],
|
58 |
outputs="image",
|
59 |
title="Foro Din谩mico con Visualizaci贸n de Red")
|
60 |
-
iface.launch(share=True)
|
61 |
-
|
|
|
13 |
# Use Directed Graph to represent relationships
|
14 |
G = nx.DiGraph() # Fix: Use DiGraph instead of Graph
|
15 |
|
16 |
+
url = f"https://api.airtable.com/v0/{AIRT_DBASEx}/{AIRT_TABLEx}"
|
17 |
+
headers = {
|
18 |
+
"Authorization": f"Bearer {api_key}",
|
19 |
+
"Content-Type": "application/json"
|
20 |
+
}
|
21 |
+
|
22 |
+
def cargar_desde_airtable():
|
23 |
+
"""Recupera los datos almacenados en AirTable y los grafica."""
|
24 |
+
aportes = []
|
25 |
+
response = requests.get(url, headers=headers)
|
26 |
+
|
27 |
+
if response.status_code == 200:
|
28 |
+
records = response.json().get("records", [])
|
29 |
+
for record in records:
|
30 |
+
node_id = record["id"]
|
31 |
+
nombre = record["fields"].get("Nombre", "")
|
32 |
+
enfoque = record["fields"].get("Enfoque", "")
|
33 |
+
norma = record['fields'].get("Norma", "")
|
34 |
+
texto = record["fields"].get("Texto_HF", "")
|
35 |
+
|
36 |
+
label = f"{norma}"
|
37 |
+
aportes.append([nombre, enfoque, norma, texto])
|
38 |
+
aportes_df = pd.DataFrame(aportes, columns=["Nombre", "Enfoque", "Norma", "Texto_HF"])
|
39 |
+
|
40 |
+
return aportes_df
|
41 |
+
|
42 |
+
def guardar_en_airtable(nombre, enfoque, norma, texto):
|
43 |
data = {"fields": {"Nombre": nombre, "Enfoque": enfoque, "Norma": norma, "Texto_HF": texto}}
|
44 |
requests.post(url, headers=headers, json=data)
|
45 |
|
|
|
78 |
inputs=["text", "text", "text", "text"],
|
79 |
outputs="image",
|
80 |
title="Foro Din谩mico con Visualizaci贸n de Red")
|
81 |
+
iface.launch(share=True)
|
|