Spaces:
Sleeping
Sleeping
working
Browse files
app.py
CHANGED
@@ -9,7 +9,13 @@ def update(name):
|
|
9 |
#return f"Welcome to Gradio, {name}!"
|
10 |
return {"name": name}
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
with gr.Blocks() as demo:
|
15 |
|
@@ -17,21 +23,14 @@ with gr.Blocks() as demo:
|
|
17 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
18 |
#gr.DuplicateButton()
|
19 |
with gr.Row():
|
20 |
-
with gr.
|
21 |
gr.Markdown("Type your message:")
|
22 |
inp = gr.Textbox(placeholder="What is your name?")
|
23 |
-
with gr.
|
24 |
out = gr.JSON()
|
25 |
btn = gr.Button("Send request to server")
|
26 |
-
btn.click(fn=
|
27 |
-
|
28 |
-
#with gr.Row():
|
29 |
-
#inp = gr.Textbox(placeholder="What is your name?")
|
30 |
-
#out = gr.JSON()
|
31 |
-
#out = gr.Textbox()
|
32 |
-
#btn = gr.Button("Run")
|
33 |
-
#btn.click(fn=update, inputs=inp, outputs=out
|
34 |
-
|
35 |
|
36 |
|
37 |
demo.launch(share=True)
|
|
|
9 |
#return f"Welcome to Gradio, {name}!"
|
10 |
return {"name": name}
|
11 |
|
12 |
+
def send_request(text):
|
13 |
+
client = Client("Nuno-Tome/API_demo_server")
|
14 |
+
result = client.predict(
|
15 |
+
text,
|
16 |
+
api_name="/predict"
|
17 |
+
)
|
18 |
+
return result
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
|
|
|
23 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
24 |
#gr.DuplicateButton()
|
25 |
with gr.Row():
|
26 |
+
with gr.Column():
|
27 |
gr.Markdown("Type your message:")
|
28 |
inp = gr.Textbox(placeholder="What is your name?")
|
29 |
+
with gr.Column():
|
30 |
out = gr.JSON()
|
31 |
btn = gr.Button("Send request to server")
|
32 |
+
btn.click(fn=send_request, inputs=inp, outputs=out)
|
33 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
demo.launch(share=True)
|