Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
7 |
demo.launch()
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Define the function to call the API
|
6 |
+
def translate(text):
|
7 |
+
url = "https://xayq0bvi0h.execute-api.eu-west-2.amazonaws.com/api/translate"
|
8 |
+
payload = json.dumps({
|
9 |
+
"text": text
|
10 |
+
})
|
11 |
+
headers = {
|
12 |
+
'Content-Type': 'application/json'
|
13 |
+
}
|
14 |
+
|
15 |
+
# Make the API request
|
16 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
17 |
+
|
18 |
+
# Return the response text
|
19 |
+
return response.text
|
20 |
|
21 |
+
# Create the Gradio interface
|
22 |
+
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
23 |
+
|
24 |
+
# Launch the Gradio app
|
25 |
demo.launch()
|