__init__.py
18 lines
| 861 B
| text/x-python
|
PythonLexer
Thomas Kluyver
|
r18482 | import os | |
from terminado import NamedTermManager | |||
Thomas Kluyver
|
r18485 | from IPython.html.utils import url_path_join as ujoin | |
Thomas Kluyver
|
r18482 | from .handlers import TerminalHandler, NewTerminalHandler, TermSocket | |
Thomas Kluyver
|
r18483 | from . import api_handlers | |
Thomas Kluyver
|
r18482 | ||
def initialize(webapp): | |||
shell = os.environ.get('SHELL', 'sh') | |||
webapp.terminal_manager = NamedTermManager(shell_command=[shell]) | |||
Thomas Kluyver
|
r18485 | base_url = webapp.settings['base_url'] | |
Thomas Kluyver
|
r18482 | handlers = [ | |
Thomas Kluyver
|
r18485 | (ujoin(base_url, "/terminals/new"), NewTerminalHandler), | |
(ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler), | |||
(ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket, | |||
Thomas Kluyver
|
r18482 | {'term_manager': webapp.terminal_manager}), | |
Thomas Kluyver
|
r18485 | (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler), | |
(ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler), | |||
Thomas Kluyver
|
r18482 | ] | |
webapp.add_handlers(".*$", handlers) |