SatCat commited on
Commit
c7b00d4
·
1 Parent(s): 8916029

add gradio

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -6,6 +6,15 @@ from starlette.routing import Route, WebSocketRoute, Mount
6
  from starlette.websockets import WebSocket
7
  from starlette.types import Message, Receive, Scope, Send
8
 
 
 
 
 
 
 
 
 
 
9
  # -------------------- shiny ------------------------
10
  import shiny
11
  from shiny import App, render, ui, reactive
@@ -79,7 +88,10 @@ html = """
79
 
80
  }
81
  </script>
82
- <iframe src="/shiny/" width="100%" height="400" style="border:1px solid blue;"></iframe>
 
 
 
83
  <div class="bottom_div"><ul class="log_msg" id="log_msg"></ul></div>
84
  </body>
85
  </html>"""
@@ -102,7 +114,7 @@ routes = [
102
  Mount('/shiny', app=app_shiny)
103
  ]
104
  app = Starlette(routes=routes)
105
-
106
 
107
  # as a main work loop..
108
  @app.on_event("startup")
 
6
  from starlette.websockets import WebSocket
7
  from starlette.types import Message, Receive, Scope, Send
8
 
9
+ # -------------------- gradio ------------------------
10
+ import gradio as gr
11
+
12
+ async def name_fn(name):
13
+ await mbase.add_msg(f'gradio_name: {name}')
14
+ return "Name: " + name + "!"
15
+
16
+ io = gr.Interface(fn=name_fn, inputs=gr.Textbox(lines=2, placeholder="Name Here..."), outputs="text")
17
+
18
  # -------------------- shiny ------------------------
19
  import shiny
20
  from shiny import App, render, ui, reactive
 
88
 
89
  }
90
  </script>
91
+ Shiny App
92
+ <iframe src="/shiny/" width="100%" height="250" style="border:1px solid blue;"></iframe>
93
+ Gradio App
94
+ <iframe src="/gradio/" width="100%" height="250" style="border:1px solid red;"></iframe>
95
  <div class="bottom_div"><ul class="log_msg" id="log_msg"></ul></div>
96
  </body>
97
  </html>"""
 
114
  Mount('/shiny', app=app_shiny)
115
  ]
116
  app = Starlette(routes=routes)
117
+ app = gr.mount_gradio_app(app, io, path='/gradio') # insert gradio app this way
118
 
119
  # as a main work loop..
120
  @app.on_event("startup")