Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,11 @@ def translate(text):
|
|
15 |
# Make the API request
|
16 |
response = requests.request("POST", url, headers=headers, data=payload)
|
17 |
|
18 |
-
#
|
19 |
-
|
|
|
|
|
|
|
20 |
|
21 |
# Create the Gradio interface
|
22 |
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
|
|
15 |
# Make the API request
|
16 |
response = requests.request("POST", url, headers=headers, data=payload)
|
17 |
|
18 |
+
# Parse the response and extract the translation
|
19 |
+
response_data = response.json() # Parse the JSON response
|
20 |
+
translation = response_data.get("translation", "Translation not found") # Get the translation
|
21 |
+
|
22 |
+
return translation
|
23 |
|
24 |
# Create the Gradio interface
|
25 |
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|