SatCat commited on
Commit
8916029
·
1 Parent(s): 59aab6a
Files changed (1) hide show
  1. app.py +3 -21
app.py CHANGED
@@ -6,16 +6,6 @@ from starlette.routing import Route, WebSocketRoute, Mount
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
- gradio_app = gr.routes.App.create_app(io)
18
-
19
  # -------------------- shiny ------------------------
20
  import shiny
21
  from shiny import App, render, ui, reactive
@@ -72,9 +62,8 @@ html = """
72
  </style>
73
  </head>
74
  <body>
75
- <script src="https://gradio.s3-us-west-2.amazonaws.com/2.6.2/static/bundle.js"></script>
76
  <script type="text/javascript">
77
- var ws = new WebSocket("wss://satcat-pyshiny-gradio-msg-test-app.hf.space/ws");
78
  ws.onmessage = function(event) {
79
  var newNode = document.createElement('li');
80
  var content = document.createTextNode(event.data);
@@ -90,13 +79,7 @@ html = """
90
 
91
  }
92
  </script>
93
- Shiny App
94
- <iframe src="/shiny/" width="100%" height="250" style="border:1px solid blue;"></iframe>
95
- Gradio App
96
- <div id="gradio_app" width="100%" height="250" style="border:1px solid red;"></div>
97
- <script>
98
- launchGradioFromSpaces("satcat/pyshiny-gradio-msg-test-app", "#gradio_app")
99
- </script>
100
  <div class="bottom_div"><ul class="log_msg" id="log_msg"></ul></div>
101
  </body>
102
  </html>"""
@@ -116,8 +99,7 @@ class Echo(WebSocketEndpoint):
116
  routes = [
117
  Route("/", Homepage),
118
  WebSocketRoute("/ws", Echo),
119
- Mount('/shiny', app=app_shiny),
120
- Mount('/gradio', app=gradio_app)
121
  ]
122
  app = Starlette(routes=routes)
123
 
 
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
 
62
  </style>
63
  </head>
64
  <body>
 
65
  <script type="text/javascript">
66
+ var ws = new WebSocket("wss://satcat-ShinyPython-with-Msgs-app.hf.space/ws");
67
  ws.onmessage = function(event) {
68
  var newNode = document.createElement('li');
69
  var content = document.createTextNode(event.data);
 
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>"""
 
99
  routes = [
100
  Route("/", Homepage),
101
  WebSocketRoute("/ws", Echo),
102
+ Mount('/shiny', app=app_shiny)
 
103
  ]
104
  app = Starlette(routes=routes)
105