Skip to content

Commit 6b8c360

Browse files
committed
add no_browser_open_files
1 parent 1c9c943 commit 6b8c360

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

jupyter_server/serverapp.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,10 @@ def _default_info_file(self):
15731573
info_file = "jpserver-%s.json" % os.getpid()
15741574
return os.path.join(self.runtime_dir, info_file)
15751575

1576+
no_browser_open_files = Bool(
1577+
False, help="If True, do not write redirect HTML files disk, or show in messages."
1578+
)
1579+
15761580
browser_open_file = Unicode()
15771581

15781582
@default("browser_open_file")
@@ -2815,9 +2819,11 @@ def start_app(self):
28152819

28162820
self.write_server_info_file()
28172821

2822+
if not self.no_browser_open_files:
2823+
self.write_browser_open_files()
2824+
28182825
# Handle the browser opening.
28192826
if self.open_browser and not self.sock:
2820-
self.write_browser_open_files()
28212827
self.launch_browser()
28222828

28232829
if self.identity_provider.token and self.identity_provider.token_generated:
@@ -2840,17 +2846,26 @@ def start_app(self):
28402846
)
28412847
)
28422848
else:
2843-
self.log.critical(
2844-
"\n".join(
2845-
[
2846-
"\n",
2849+
if self.no_browser_open_files:
2850+
message = [
2851+
"\n",
2852+
_i18n("To access the server, copy and paste one of these URLs:"),
2853+
" %s" % self.display_url,
2854+
]
2855+
else:
2856+
message = [
2857+
"\n",
2858+
_i18n(
28472859
"To access the server, open this file in a browser:",
2848-
" %s" % urljoin("file:", pathname2url(self.browser_open_file)),
2860+
),
2861+
" %s" % urljoin("file:", pathname2url(self.browser_open_file)),
2862+
_i18n(
28492863
"Or copy and paste one of these URLs:",
2850-
" %s" % self.display_url,
2851-
]
2852-
)
2853-
)
2864+
),
2865+
" %s" % self.display_url,
2866+
]
2867+
2868+
self.log.critical("\n".join(message))
28542869

28552870
async def _cleanup(self):
28562871
"""General cleanup of files, extensions and kernels created

0 commit comments

Comments
 (0)