Skip to content

Commit 284207e

Browse files
committed
add support for multiple endpoints, configured via JUPYTER_REMOTE_DESKTOP_ENDPOINTS
1 parent 1742149 commit 284207e

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

js/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ function status(text) {
4545
// This page is served under the /desktop/, and the websockify websocket is served
4646
// under /desktop-websockify/ with the same base url as /desktop/. We resolve it relatively
4747
// this way.
48-
let websockifyUrl = new URL("../desktop-websockify/", window.location);
48+
let websockifyUrl = new URL(
49+
window.location.pathname.replace(/\/+$/, "") + "-websockify/",
50+
window.location,
51+
);
4952
websockifyUrl.protocol = window.location.protocol === "https:" ? "wss" : "ws";
5053

5154
let retryCount = 0;
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23

34
from 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

Comments
 (0)