Update app.py
Browse files
app.py
CHANGED
|
@@ -25,12 +25,18 @@ import gradio as gr
|
|
| 25 |
def my_function(name):
|
| 26 |
return "Hello " + name + "!!"
|
| 27 |
|
| 28 |
-
# Create a Gradio app.
|
| 29 |
-
app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'])
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
app.
|
| 33 |
|
| 34 |
# Launch the Gradio app.
|
| 35 |
app.launch()
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def my_function(name):
|
| 26 |
return "Hello " + name + "!!"
|
| 27 |
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Create a Gradio app.
|
| 30 |
+
app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'], allow_external_requests=True)
|
| 31 |
|
| 32 |
# Launch the Gradio app.
|
| 33 |
app.launch()
|
| 34 |
|
| 35 |
+
# Make a POST request to the URL of the Gradio app.
|
| 36 |
+
data = {'text': 'This is a test.'}
|
| 37 |
+
response = requests.post(app.url, data=data)
|
| 38 |
+
|
| 39 |
+
# The response to the POST request will be the output of the Gradio app.
|
| 40 |
+
output = response.json()['output']
|
| 41 |
+
|
| 42 |
+
|