Spaces:
Build error
Build error
Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
import pprint
|
| 5 |
+
|
| 6 |
+
def greet(MESSAGE, API_KEY):
|
| 7 |
+
url = "https://9byf8l4qzk.execute-api.eu-west-2.amazonaws.com/dev/sar-alert-container"
|
| 8 |
+
payload = json.dumps({"message": MESSAGE})
|
| 9 |
+
headers = {
|
| 10 |
+
'Content-Type': 'application/json',
|
| 11 |
+
'x-api-key': API_KEY
|
| 12 |
+
}
|
| 13 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
| 14 |
+
pprint.pprint(json.loads(response.text))
|
| 15 |
+
return str(json.loads(response.text))
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
fn=greet,
|
| 19 |
+
inputs=["text", "text"],
|
| 20 |
+
outputs="text")
|
| 21 |
+
|
| 22 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==3.38.0
|
| 2 |
+
requests==2.28.1
|