-
Notifications
You must be signed in to change notification settings - Fork 94
/
uimod.py
34 lines (30 loc) · 1.33 KB
/
uimod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""A single common terminal for all websockets.
"""
import tornado.web
# This demo requires tornado_xstatic and XStatic-term.js
import tornado_xstatic
from terminado import TermSocket, SingleTermManager
from terminado import uimodule
from common_demo_stuff import run_and_show_browser, STATIC_DIR, TEMPLATE_DIR
class TerminalPageHandler(tornado.web.RequestHandler):
def get(self):
return self.render("uimod.html", static=self.static_url,
xstatic=self.application.settings['xstatic_url'],
ws_url_path="/websocket")
def main(argv):
term_manager = SingleTermManager(shell_command=['bash'])
handlers = [
(r"/websocket", TermSocket,
{'term_manager': term_manager}),
(r"/", TerminalPageHandler),
(r"/xstatic/(.*)", tornado_xstatic.XStaticFileHandler,
{'allowed_modules': ['termjs']})
]
app = tornado.web.Application(handlers, static_path=STATIC_DIR,
template_path=TEMPLATE_DIR,
ui_modules = {'Terminal': uimodule.Terminal},
xstatic_url = tornado_xstatic.url_maker('/xstatic/'))
app.listen(8765, 'localhost')
run_and_show_browser("http://localhost:8765/", term_manager)
if __name__ == '__main__':
main([])