umair894 commited on
Commit
8e7a470
·
verified ·
1 Parent(s): c4da5df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,9 +1,31 @@
1
  import gradio as gr
2
-
3
  def greet(name):
4
  return "Hello " + name*5
5
 
6
- demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  if __name__ == "__main__":
9
  demo.launch()
 
1
  import gradio as gr
2
+ import requests
3
  def greet(name):
4
  return "Hello " + name*5
5
 
6
+ url = "https://sentiment-analysis9.p.rapidapi.com/sentiment"
7
+ #user_input = input("Please enter a text for sentiment analysis: ")
8
+ def call_sentiment_api(user_input):
9
+ payload = [
10
+ {
11
+ "id": "1",
12
+ "language": "en",
13
+ "text":user_input
14
+ }
15
+ ]
16
+ headers = {
17
+ "content-type": "application/json",
18
+ "Accept": "application/json",
19
+ "X-RapidAPI-Key": "5cf8fcaf61msh613f010a34f3576p1953e5jsn110a1e6c667d",
20
+ "X-RapidAPI-Host": "sentiment-analysis9.p.rapidapi.com"
21
+ }
22
+
23
+ response = requests.post(url, json=payload, headers=headers)
24
+
25
+ print(response.json())
26
+ return response.json()
27
+
28
+ demo = gr.Interface(fn=call_sentiment_api, inputs="textbox", outputs="textbox")
29
 
30
  if __name__ == "__main__":
31
  demo.launch()