Upload 2 files
Browse files- app.py +39 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
BASE_URL = "https://green-guard-cyber-ai-api.vercel.app"
|
| 5 |
+
|
| 6 |
+
def fetch_latest():
|
| 7 |
+
res = requests.get(f"{BASE_URL}/insights/latest")
|
| 8 |
+
return res.json()
|
| 9 |
+
|
| 10 |
+
def fetch_by_index(index):
|
| 11 |
+
res = requests.get(f"{BASE_URL}/insights/{int(index)}")
|
| 12 |
+
return res.json()
|
| 13 |
+
|
| 14 |
+
def fetch_top(limit):
|
| 15 |
+
res = requests.get(f"{BASE_URL}/insights?limit={int(limit)}")
|
| 16 |
+
return res.json()
|
| 17 |
+
|
| 18 |
+
with gr.Blocks() as demo:
|
| 19 |
+
gr.Markdown("## πΏ GreenGuard ESG Intel Explorer")
|
| 20 |
+
gr.Markdown("Built by Allsafeafrica β powered by Hugging Face + FastAPI")
|
| 21 |
+
|
| 22 |
+
with gr.Tab("π Latest Insight"):
|
| 23 |
+
btn_latest = gr.Button("Fetch Latest ESG Entry")
|
| 24 |
+
out_latest = gr.JSON()
|
| 25 |
+
btn_latest.click(fn=fetch_latest, outputs=out_latest)
|
| 26 |
+
|
| 27 |
+
with gr.Tab("π Get by Index"):
|
| 28 |
+
idx = gr.Number(label="Index", value=0)
|
| 29 |
+
btn_idx = gr.Button("Fetch Entry")
|
| 30 |
+
out_idx = gr.JSON()
|
| 31 |
+
btn_idx.click(fn=fetch_by_index, inputs=idx, outputs=out_idx)
|
| 32 |
+
|
| 33 |
+
with gr.Tab("π Top N Records"):
|
| 34 |
+
slider = gr.Slider(minimum=1, maximum=50, step=1, label="How many entries?", value=10)
|
| 35 |
+
btn_all = gr.Button("Fetch")
|
| 36 |
+
out_all = gr.JSON()
|
| 37 |
+
btn_all.click(fn=fetch_top, inputs=slider, outputs=out_all)
|
| 38 |
+
|
| 39 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
requests
|