Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,9 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
import pprint
|
|
|
|
| 5 |
|
| 6 |
-
def
|
| 7 |
url = "https://9byf8l4qzk.execute-api.eu-west-2.amazonaws.com/dev/sar-alert-container"
|
| 8 |
payload = json.dumps({"message": MESSAGE})
|
| 9 |
headers = {
|
|
@@ -11,12 +12,16 @@ def greet(MESSAGE, API_KEY):
|
|
| 11 |
'x-api-key': API_KEY
|
| 12 |
}
|
| 13 |
response = requests.request("POST", url, headers=headers, data=payload)
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
iface = gr.Interface(
|
| 18 |
-
fn=
|
| 19 |
inputs=["text", "text"],
|
| 20 |
-
outputs="text"
|
|
|
|
| 21 |
|
| 22 |
iface.launch()
|
|
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
import pprint
|
| 5 |
+
import pandas as pd
|
| 6 |
|
| 7 |
+
def sar_alert(MESSAGE, API_KEY):
|
| 8 |
url = "https://9byf8l4qzk.execute-api.eu-west-2.amazonaws.com/dev/sar-alert-container"
|
| 9 |
payload = json.dumps({"message": MESSAGE})
|
| 10 |
headers = {
|
|
|
|
| 12 |
'x-api-key': API_KEY
|
| 13 |
}
|
| 14 |
response = requests.request("POST", url, headers=headers, data=payload)
|
| 15 |
+
output_data = json.loads(response.text)
|
| 16 |
+
#
|
| 17 |
+
pprint.pprint(output_data)
|
| 18 |
+
df_response = pd.json_normalize(output_data)
|
| 19 |
+
return df_response, str(output_data)
|
| 20 |
|
| 21 |
iface = gr.Interface(
|
| 22 |
+
fn=sar_alert,
|
| 23 |
inputs=["text", "text"],
|
| 24 |
+
outputs=[gr.outputs.Dataframe(),"text"]
|
| 25 |
+
)
|
| 26 |
|
| 27 |
iface.launch()
|