with post req
Browse files
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
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
iface = gr.Interface(fn=greet, inputs=["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()
|