Skip to content

Commit 841bdcf

Browse files
committed
allow to have multiple desktop endpoints, and relocate the endpoint to remove -websockify
1 parent 1742149 commit 841bdcf

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

js/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ function status(text) {
4242
document.getElementById("status").textContent = text;
4343
}
4444

45-
// This page is served under the /desktop/, and the websockify websocket is served
46-
// under /desktop-websockify/ with the same base url as /desktop/. We resolve it relatively
45+
// This page is served under the /desktopvnc/, and the websockify websocket is served
46+
// under /desktop/ with the same base url as /desktopvnc/. We resolve it relatively
4747
// this way.
48-
let websockifyUrl = new URL("../desktop-websockify/", window.location);
48+
let websockifyUrl = new URL("../desktop/", window.location);
4949
websockifyUrl.protocol = window.location.protocol === "https:" ? "wss" : "ws";
5050

5151
let retryCount = 0;

jupyter_remote_desktop_proxy/server_extension.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from jupyter_server_proxy.handlers import AddSlashHandler
66

77
from .handlers import DesktopHandler
8-
8+
import os
99
HERE = Path(__file__).parent
1010

1111

@@ -15,18 +15,21 @@ def load_jupyter_server_extension(server_app):
1515
"""
1616
base_url = server_app.web_app.settings["base_url"]
1717

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-
)
18+
jupyter_remote_desktop_endpoints = os.getenv('JUPYTER_REMOTE_DESKTOP_ENDPOINTS', 'desktopvnc')
19+
endpoints = jupyter_remote_desktop_endpoints.split(',')
20+
for endpoint in endpoints:
21+
server_app.web_app.add_handlers(
22+
".*",
23+
[
24+
# Serve our own static files
25+
(
26+
url_path_join(base_url, f"/{endpoint}/static/(.*)"),
27+
AuthenticatedFileHandler,
28+
{"path": (str(HERE / "static"))},
29+
),
30+
# To simplify URL mapping, we make sure that /desktop/ always
31+
# has a trailing slash
32+
(url_path_join(base_url, f"/{endpoint}"), AddSlashHandler),
33+
(url_path_join(base_url, f"/{endpoint}/"), DesktopHandler),
34+
],
35+
)

jupyter_remote_desktop_proxy/setup_websockify.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def setup_websockify():
5656
'command': ['/bin/sh', '-c', f'cd {os.getcwd()} && {vnc_command}'],
5757
'timeout': 30,
5858
'new_browser_window': True,
59-
# We want the launcher entry to point to /desktop/, not to /desktop-websockify/
60-
# /desktop/ is the user facing URL, while /desktop-websockify/ now *only* serves
59+
# We want the launcher entry to point to /desktopvnc/, not to /desktop/
60+
# /desktop/ is the user facing URL, while /desktop/ now *only* serves
6161
# websockets.
62-
"launcher_entry": {"title": "Desktop", "path_info": "desktop"},
62+
"launcher_entry": {"title": "Desktop", "path_info": "desktopvnc"},
6363
"unix_socket": True,
6464
"raw_socket_proxy": True,
6565
}

jupyter_remote_desktop_proxy/templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
Chrome Frame. -->
1414
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
1515

16-
<link href="{{ base_url }}desktop/static/dist/index.css" rel="stylesheet" />
16+
<link href="{{ base_url }}desktopvnc/static/dist/index.css" rel="stylesheet" />
1717
</head>
1818

1919
<body>
2020
<div id="top-bar">
2121
<a href=".." id="logo">
22-
<img src="{{base_url}}desktop/static/jupyter-logo.svg" />
22+
<img src="{{base_url}}desktopvnc/static/jupyter-logo.svg" />
2323
</a>
2424
<ul id="menu">
2525
<li id="status-container">
@@ -52,6 +52,6 @@
5252
</div>
5353
</div>
5454

55-
<script src="{{base_url}}desktop/static/dist/viewer.js"></script>
55+
<script src="{{base_url}}desktopvnc/static/dist/viewer.js"></script>
5656
</body>
5757
</html>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def run(self):
6060
description="Run a desktop environments on Jupyter",
6161
entry_points={
6262
'jupyter_serverproxy_servers': [
63-
'desktop-websockify = jupyter_remote_desktop_proxy.setup_websockify:setup_websockify',
63+
'desktop = jupyter_remote_desktop_proxy.setup_websockify:setup_websockify',
6464
]
6565
},
6666
install_requires=[

tests/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_desktop(browser):
4949
with page.expect_popup() as page1_info:
5050
page.get_by_text("Desktop [↗]").click()
5151
page1 = page1_info.value
52-
page1.wait_for_url(f"{JUPYTER_HOST}/desktop/")
52+
page1.wait_for_url(f"{JUPYTER_HOST}/desktopvnc/")
5353

5454
expect(page1.get_by_text("Status: Connected")).to_be_visible()
5555
expect(page1.locator("canvas")).to_be_visible()

0 commit comments

Comments
 (0)