Skip to content

Instantly share code, notes, and snippets.

@fifar
Created April 13, 2020 04:17
Show Gist options
  • Save fifar/6011f9a31d0fb9f52883732c0c977677 to your computer and use it in GitHub Desktop.
Save fifar/6011f9a31d0fb9f52883732c0c977677 to your computer and use it in GitHub Desktop.
TensorBoard 2.2.0 patch
diff --git a/tensorboard/notebook.py b/tensorboard/notebook.py
index fe0e13aa..ab774377 100644
--- a/tensorboard/notebook.py
+++ b/tensorboard/notebook.py
@@ -378,8 +378,17 @@ def _display_ipython(port, height, display_handle):
<script>
(function() {
const frame = document.getElementById(%JSON_ID%);
- const url = new URL("/", window.location);
- url.port = %PORT%;
+ var baseUrl = "/";
+ try {
+ // parse baseUrl in JupyterLab
+ baseUrl = JSON.parse(document.getElementById('jupyter-config-data').text || '').baseUrl;
+ } catch {
+ try {
+ // parse baseUrl in classic Jupyter
+ baseUrl = $('body').data('baseUrl');
+ } catch {}
+ }
+ const url = new URL(baseUrl, window.location) + "proxy/%PORT%/";
frame.src = url;
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment