99from collections import namedtuple
1010from .utils import call_with_asked_args
1111
12- def _make_serverproxy_handler (name , command , environment , timeout , absolute_url , port ):
12+ def _make_serverproxy_handler (name , command , environment , timeout , absolute_url , port , mappath ):
1313 """
1414 Create a SuperviseAndProxyHandler subclass with given parameters
1515 """
@@ -21,6 +21,7 @@ def __init__(self, *args, **kwargs):
2121 self .proxy_base = name
2222 self .absolute_url = absolute_url
2323 self .requested_port = port
24+ self .mappath = mappath
2425
2526 @property
2627 def process_args (self ):
@@ -82,6 +83,7 @@ def make_handlers(base_url, server_processes):
8283 sp .timeout ,
8384 sp .absolute_url ,
8485 sp .port ,
86+ sp .mappath ,
8587 )
8688 handlers .append ((
8789 ujoin (base_url , sp .name , r'(.*)' ), handler , dict (state = {}),
@@ -93,7 +95,7 @@ def make_handlers(base_url, server_processes):
9395
9496LauncherEntry = namedtuple ('LauncherEntry' , ['enabled' , 'icon_path' , 'title' ])
9597ServerProcess = namedtuple ('ServerProcess' , [
96- 'name' , 'command' , 'environment' , 'timeout' , 'absolute_url' , 'port' , 'launcher_entry' ])
98+ 'name' , 'command' , 'environment' , 'timeout' , 'absolute_url' , 'port' , 'mappath' , ' launcher_entry' ])
9799
98100def make_server_process (name , server_process_config ):
99101 le = server_process_config .get ('launcher_entry' , {})
@@ -104,6 +106,7 @@ def make_server_process(name, server_process_config):
104106 timeout = server_process_config .get ('timeout' , 5 ),
105107 absolute_url = server_process_config .get ('absolute_url' , False ),
106108 port = server_process_config .get ('port' , 0 ),
109+ mappath = server_process_config .get ('mappath' , {}),
107110 launcher_entry = LauncherEntry (
108111 enabled = le .get ('enabled' , True ),
109112 icon_path = le .get ('icon_path' ),
@@ -144,6 +147,11 @@ class ServerProxy(Configurable):
144147 port
145148 Set the port that the service will listen on. The default is to automatically select an unused port.
146149
150+ mappath
151+ Map request paths to proxied paths.
152+ Either a dictionary of request paths to proxied paths,
153+ or a callable that takes parameter ``path`` and returns the proxied path.
154+
147155 launcher_entry
148156 A dictionary of various options for entries in classic notebook / jupyterlab launchers.
149157
0 commit comments