1+ import os
12from pathlib import Path
23
34from jupyter_server .base .handlers import AuthenticatedFileHandler
@@ -15,18 +16,21 @@ def load_jupyter_server_extension(server_app):
1516 """
1617 base_url = server_app .web_app .settings ["base_url" ]
1718
18- server_app .web_app .add_handlers (
19- ".*" ,
20- [
21- # Serve our own static files
22- (
23- url_path_join (base_url , "/desktop/static/(.*)" ),
24- AuthenticatedFileHandler ,
25- {"path" : (str (HERE / "static" ))},
26- ),
27- # To simplify URL mapping, we make sure that /desktop/ always
28- # has a trailing slash
29- (url_path_join (base_url , "/desktop" ), AddSlashHandler ),
30- (url_path_join (base_url , "/desktop/" ), DesktopHandler ),
31- ],
32- )
19+ jupyter_remote_desktop_endpoints = os .getenv ('JUPYTER_REMOTE_DESKTOP_ENDPOINTS' , '' )
20+ endpoints = ['desktop' ] + jupyter_remote_desktop_endpoints .split (',' )
21+ for endpoint in endpoints :
22+ server_app .web_app .add_handlers (
23+ ".*" ,
24+ [
25+ # Serve our own static files
26+ (
27+ url_path_join (base_url , f"/{ endpoint } /static/(.*)" ),
28+ AuthenticatedFileHandler ,
29+ {"path" : (str (HERE / "static" ))},
30+ ),
31+ # To simplify URL mapping, we make sure that /desktop/ always
32+ # has a trailing slash
33+ (url_path_join (base_url , f"/{ endpoint } " ), AddSlashHandler ),
34+ (url_path_join (base_url , f"/{ endpoint } /" ), DesktopHandler ),
35+ ],
36+ )
0 commit comments