Spaces:
Sleeping
Sleeping
code update
Browse files
app.py
CHANGED
|
@@ -19,13 +19,22 @@ It is made of 2 components: *API_demo_server* and *API_demo_client*.
|
|
| 19 |
**Just write you message and watch it be returned by the server.**
|
| 20 |
|
| 21 |
"""
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def get_bmc_markdown():
|
| 25 |
bmc_link = "https://www.buymeacoffee.com/nuno.tome"
|
| 26 |
image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png" # Image URL
|
| 27 |
image_size = "150" # Image size
|
| 28 |
-
image_url_full = image_url + "?w=" + image_size
|
| 29 |
image_link_markdown = f"[]({bmc_link})"
|
| 30 |
full_text = """
|
| 31 |
### If you like this project, please consider liking it or buying me a coffee. It will help me to keep working on this and other projects. Thank you!
|
|
@@ -37,7 +46,7 @@ def send_request(text):
|
|
| 37 |
server = Client("Nuno-Tome/API_demo_server")
|
| 38 |
result = server.predict(
|
| 39 |
text,
|
| 40 |
-
api_name="/predict"
|
| 41 |
)
|
| 42 |
return result
|
| 43 |
|
|
@@ -50,18 +59,17 @@ with gr.Blocks() as demo:
|
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
| 52 |
input_text = gr.TextArea(
|
| 53 |
-
placeholder=
|
| 54 |
-
label=
|
| 55 |
)
|
| 56 |
input_server = gr.Textbox(
|
| 57 |
lines = 1,
|
| 58 |
-
placeholder = "
|
| 59 |
-
label=
|
| 60 |
-
)
|
| 61 |
with gr.Column():
|
| 62 |
gr.Markdown("**This is your gradio api request response:**")
|
| 63 |
out = gr.JSON()
|
| 64 |
btn = gr.Button("Send request to server")
|
| 65 |
-
btn.click(fn=send_request, inputs=input_text, outputs=out)
|
| 66 |
|
| 67 |
-
demo.launch(share=True)
|
|
|
|
| 19 |
**Just write you message and watch it be returned by the server.**
|
| 20 |
|
| 21 |
"""
|
| 22 |
+
|
| 23 |
+
INPUT_TEXT_EXAMPLE = """
|
| 24 |
+
Não sou nada.
|
| 25 |
+
Nunca serei nada.
|
| 26 |
+
Não posso querer ser nada.
|
| 27 |
+
À parte isso, tenho em mim todos os sonhos do mundo.
|
| 28 |
+
(...)
|
| 29 |
+
|
| 30 |
+
- Alvaro de Campos, in "Tabacaria" (Fernando Pessoa)
|
| 31 |
+
"""
|
| 32 |
|
| 33 |
def get_bmc_markdown():
|
| 34 |
bmc_link = "https://www.buymeacoffee.com/nuno.tome"
|
| 35 |
image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png" # Image URL
|
| 36 |
image_size = "150" # Image size
|
| 37 |
+
image_url_full = image_url + "?w = " + image_size
|
| 38 |
image_link_markdown = f"[]({bmc_link})"
|
| 39 |
full_text = """
|
| 40 |
### If you like this project, please consider liking it or buying me a coffee. It will help me to keep working on this and other projects. Thank you!
|
|
|
|
| 46 |
server = Client("Nuno-Tome/API_demo_server")
|
| 47 |
result = server.predict(
|
| 48 |
text,
|
| 49 |
+
api_name = "/predict"
|
| 50 |
)
|
| 51 |
return result
|
| 52 |
|
|
|
|
| 59 |
with gr.Row():
|
| 60 |
with gr.Column():
|
| 61 |
input_text = gr.TextArea(
|
| 62 |
+
placeholder = INPUT_TEXT_EXAMPLE,
|
| 63 |
+
label = "**Type your message:**"
|
| 64 |
)
|
| 65 |
input_server = gr.Textbox(
|
| 66 |
lines = 1,
|
| 67 |
+
placeholder = "Nuno-Tome/API_demo_server",
|
| 68 |
+
label = "**Type the server to call:**")
|
|
|
|
| 69 |
with gr.Column():
|
| 70 |
gr.Markdown("**This is your gradio api request response:**")
|
| 71 |
out = gr.JSON()
|
| 72 |
btn = gr.Button("Send request to server")
|
| 73 |
+
btn.click(fn = send_request, inputs = input_text, outputs = out)
|
| 74 |
|
| 75 |
+
demo.launch(share = True)
|