Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
def greet(name): | |
return "Hello " + name*5 | |
url = "https://sentiment-analysis9.p.rapidapi.com/sentiment" | |
#user_input = input("Please enter a text for sentiment analysis: ") | |
def call_sentiment_api(user_input): | |
payload = [ | |
{ | |
"id": "1", | |
"language": "en", | |
"text":user_input | |
} | |
] | |
headers = { | |
"content-type": "application/json", | |
"Accept": "application/json", | |
"X-RapidAPI-Key": "5cf8fcaf61msh613f010a34f3576p1953e5jsn110a1e6c667d", | |
"X-RapidAPI-Host": "sentiment-analysis9.p.rapidapi.com" | |
} | |
response = requests.post(url, json=payload, headers=headers) | |
print(response.json()) | |
return response.json() | |
demo = gr.Interface(fn=call_sentiment_api, inputs="textbox", outputs="textbox") | |
if __name__ == "__main__": | |
demo.launch() |