Nuno-Tome commited on
Commit
6fc159a
Β·
1 Parent(s): 2801dbc

done and tested

Browse files
Files changed (2) hide show
  1. app copy 2.py +0 -63
  2. app.py +36 -5
app copy 2.py DELETED
@@ -1,63 +0,0 @@
1
- import gradio as gr
2
- from gradio_client import Client
3
-
4
- MESAGE_HEADER = """
5
- # API Demo (Client component)
6
- Welcome to my simple demonstration of the gradio potential as an API.
7
-
8
- It is made of 2 components: *API_demo_server* and *API_demo_client*.
9
-
10
- Server component: [Nuno-Tome/API_demo_server](Nuno-Tome/aPI_demo_server)
11
- Client component: [Nuno-Tome/API_demo_client](Nuno-Tome/aPI_demo_client)
12
-
13
- **Just write you message and watch it be returned by the server.**
14
-
15
- """
16
-
17
-
18
-
19
- MESAGE_BMC = """
20
- ## If you want to support me, you can buy me a coffee:
21
-
22
- [![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/nunotome)
23
- """
24
-
25
- # Print the message header for "By me a coffee" link
26
- def print_bmc():
27
-
28
- bmc_link = "https://www.buymeacoffee.com/nuno.tome"
29
- image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png?w=" # Image URL
30
- #image_size = "150px" # Image size
31
- #image_link_markdown = f"[![Buy Me a Coffee]({image_url})]({bmc_link})"
32
- image_link_markdown = "[![Buy Me a Coffee]({image_url})]({bmc_link})"
33
-
34
- gr.Markdown("""
35
- [![Buy Me a Coffee]({image_url})]({bmc_link})
36
- """)
37
- # Buy me a Coffee Setup
38
-
39
-
40
-
41
-
42
-
43
- client = Client("Nuno-Tome/API_demo_server")
44
- DEBUG_MODE = True
45
-
46
-
47
- def request(text):
48
-
49
- gr.Markdown(
50
- """
51
- # Hello World!
52
- Start typing below to see the output.
53
- """)
54
-
55
- result = client.predict(
56
- text,
57
- api_name="/predict"
58
- )
59
- return result
60
-
61
- demo = gr.Interface(fn=request, inputs="textbox", outputs="json")
62
-
63
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -4,6 +4,35 @@ from gradio_client import Client
4
 
5
  DEBUG_MODE = True
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  def update(name):
9
  #return f"Welcome to Gradio, {name}!"
@@ -19,15 +48,17 @@ def send_request(text):
19
 
20
  with gr.Blocks() as demo:
21
 
22
- with gr.Row():
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
 
 
4
 
5
  DEBUG_MODE = True
6
 
7
+ MESAGE_HEADER = """
8
+ # πŸ”ŒπŸ‘©πŸ»β€πŸ’» API Demo (Client component) πŸ”ŒπŸ‘©πŸ»β€πŸ’»
9
+
10
+
11
+ Welcome to my simple demonstration of the gradio potential as an API.
12
+
13
+ It is made of 2 components: *API_demo_server* and *API_demo_client*.
14
+
15
+ * Server component: πŸ”ŒπŸŒ [Nuno-Tome/API_demo_server](Nuno-Tome/aPI_demo_server)
16
+
17
+ * Client component: πŸ”ŒπŸ‘©πŸ»β€πŸ’» [Nuno-Tome/API_demo_client](Nuno-Tome/aPI_demo_client)
18
+
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"[![Buy Me a Coffee]({image_url_full})]({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!
32
+ # """ + image_link_markdown
33
+ return full_text
34
+
35
+
36
 
37
  def update(name):
38
  #return f"Welcome to Gradio, {name}!"
 
48
 
49
  with gr.Blocks() as demo:
50
 
51
+ gr.Markdown(MESAGE_HEADER)
52
+ gr.Markdown(get_bmc_markdown())
53
+ #gr.DuplicateButton()
54
+
55
  with gr.Row():
56
  with gr.Column():
57
+ gr.Markdown("**Type your message:**")
58
  inp = gr.Textbox(placeholder="What is your name?")
59
  with gr.Column():
60
+ gr.Markdown("**This is your gradio api request response:**")
61
+ out = gr.JSON()
62
  btn = gr.Button("Send request to server")
63
  btn.click(fn=send_request, inputs=inp, outputs=out)
64