import os
from terminado import NamedTermManager
from .handlers import TerminalHandler, NewTerminalHandler, TermSocket
from . import api_handlers

def initialize(webapp):
    shell = os.environ.get('SHELL', 'sh')
    webapp.terminal_manager = NamedTermManager(shell_command=[shell])
    handlers = [
        (r"/terminals/new", NewTerminalHandler),
        (r"/terminals/(\w+)", TerminalHandler),
        (r"/terminals/websocket/(\w+)", TermSocket,
             {'term_manager': webapp.terminal_manager}),
        (r"/api/terminals", api_handlers.TerminalRootHandler),
        (r"/api/terminals/(\w+)", api_handlers.TerminalHandler),
    ]
    webapp.add_handlers(".*$", handlers)
import os
from terminado import NamedTermManager
from IPython.html.utils import url_path_join as ujoin
from .handlers import TerminalHandler, NewTerminalHandler, TermSocket
from . import api_handlers

def initialize(webapp):
    shell = os.environ.get('SHELL', 'sh')
    webapp.terminal_manager = NamedTermManager(shell_command=[shell])
    base_url = webapp.settings['base_url']
    handlers = [
        (ujoin(base_url, "/terminals/new"), NewTerminalHandler),
        (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
        (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
             {'term_manager': webapp.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)
Put terminal handlers under base_url
Put terminal handlers under base_url

  import os
  from terminado import NamedTermManager
+ from IPython.html.utils import url_path_join as ujoin
  from .handlers import TerminalHandler, NewTerminalHandler, TermSocket
  from . import api_handlers
  
  def initialize(webapp):
      shell = os.environ.get('SHELL', 'sh')
      webapp.terminal_manager = NamedTermManager(shell_command=[shell])
+     base_url = webapp.settings['base_url']
      handlers = [
-         (r"/terminals/new", NewTerminalHandler),
+         (ujoin(base_url, "/terminals/new"), NewTerminalHandler),
-         (r"/terminals/(\w+)", TerminalHandler),
+         (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
-         (r"/terminals/websocket/(\w+)", TermSocket,
+         (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
               {'term_manager': webapp.terminal_manager}),
-         (r"/api/terminals", api_handlers.TerminalRootHandler),
+         (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
-         (r"/api/terminals/(\w+)", api_handlers.TerminalHandler),
+         (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
      ]
      webapp.add_handlers(".*$", handlers)
Put terminal handlers under base_url
## Code Before:
import os
from terminado import NamedTermManager
from .handlers import TerminalHandler, NewTerminalHandler, TermSocket
from . import api_handlers

def initialize(webapp):
    shell = os.environ.get('SHELL', 'sh')
    webapp.terminal_manager = NamedTermManager(shell_command=[shell])
    handlers = [
        (r"/terminals/new", NewTerminalHandler),
        (r"/terminals/(\w+)", TerminalHandler),
        (r"/terminals/websocket/(\w+)", TermSocket,
             {'term_manager': webapp.terminal_manager}),
        (r"/api/terminals", api_handlers.TerminalRootHandler),
        (r"/api/terminals/(\w+)", api_handlers.TerminalHandler),
    ]
    webapp.add_handlers(".*$", handlers)
## Instruction:
Put terminal handlers under base_url
## Code After:
import os
from terminado import NamedTermManager
from IPython.html.utils import url_path_join as ujoin
from .handlers import TerminalHandler, NewTerminalHandler, TermSocket
from . import api_handlers

def initialize(webapp):
    shell = os.environ.get('SHELL', 'sh')
    webapp.terminal_manager = NamedTermManager(shell_command=[shell])
    base_url = webapp.settings['base_url']
    handlers = [
        (ujoin(base_url, "/terminals/new"), NewTerminalHandler),
        (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
        (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
             {'term_manager': webapp.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)