mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
96183a60a0
instead of GET terminals/new to be consistent with creating new notebooks. We had to stop using GET notebooks/new because browsers would create new notebooks when making preview thumbnails for commonly visited pages, etc. I assume the same issue would apply to terminals
18 lines
800 B
Python
18 lines
800 B
Python
import os
|
|
from terminado import NamedTermManager
|
|
from IPython.html.utils import url_path_join as ujoin
|
|
from .handlers import TerminalHandler, TermSocket
|
|
from . import api_handlers
|
|
|
|
def initialize(webapp):
|
|
shell = os.environ.get('SHELL', 'sh')
|
|
terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(shell_command=[shell])
|
|
base_url = webapp.settings['base_url']
|
|
handlers = [
|
|
(ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
|
|
(ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
|
|
{'term_manager': terminal_manager}),
|
|
(ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
|
|
(ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
|
|
]
|
|
webapp.add_handlers(".*$", handlers) |