Ra-Is commited on
Commit
a2c48e6
1 Parent(s): d29419c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -1,7 +1,25 @@
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
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()