Shima111 commited on
Commit
48baad8
·
1 Parent(s): bd071f7

with post req

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -1,18 +1,23 @@
1
  import gradio as gr
2
  import requests
 
3
 
4
- url = 'https://randomfox.ca/floof/'
5
 
6
 
7
 
8
- def greet(name, surname):
9
- r = requests.get(url)
10
 
11
- print(r.status_code) # 200 (hopefully)
 
 
 
12
 
13
- print(r.text) # { "image": "image.jpg", "link": "link.com" }
14
- print(r.json()['image'])
15
- return "Hello " + name + "!!" + surname
 
 
16
 
17
- iface = gr.Interface(fn=greet, inputs=["text", "checkbox"], outputs="text")
18
  iface.launch()
 
1
  import gradio as gr
2
  import requests
3
+ import json
4
 
 
5
 
6
 
7
 
8
+ def greet(name):
9
+
10
 
11
+
12
+ url = "https://us-central1-samaibackend.cloudfunctions.net/happyAI/pictures"
13
+ payload = {"myPrompt": "cat"}
14
+ headers = {"Content-Type": "application/json"}
15
 
16
+ response = requests.post(url, data=json.dumps(payload), headers=headers)
17
+ result = response.json()
18
+ print(result)
19
+
20
+ return "Hello " + name + "!!"
21
 
22
+ iface = gr.Interface(fn=greet, inputs=["text"], outputs="text")
23
  iface.launch()