diff --git a/examples/simple/pyproject.toml b/examples/simple/pyproject.toml index 9dec3e55c7..ff8cef5b25 100644 --- a/examples/simple/pyproject.toml +++ b/examples/simple/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "jupyter-server-example" description = "Jupyter Server Example" readme = "README.md" -license = "MIT" +license = "BSD-3-Clause" requires-python = ">=3.9" dependencies = [ "jinja2", diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 604cd01388..036fcd3044 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -3060,6 +3060,24 @@ def start_app(self) -> None: ) self.exit(1) + info = self.log.info + for line in self.running_server_info(kernel_count=False).split("\n"): + info(line) + info( + _i18n( + "Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)." + ) + ) + if "dev" in __version__: + info( + _i18n( + "Welcome to Project Jupyter! Explore the various tools available" + " and their corresponding documentation. If you are interested" + " in contributing to the platform, please visit the community" + " resources section at https://jupyter.org/community.html." + ) + ) + self.write_server_info_file() if not self.no_browser_open_file: @@ -3069,6 +3087,46 @@ def start_app(self) -> None: if self.open_browser and not self.sock: self.launch_browser() + if self.identity_provider.token and self.identity_provider.token_generated: + # log full URL with generated token, so there's a copy/pasteable link + # with auth info. + if self.sock: + self.log.critical( + "\n".join( + [ + "\n", + "Jupyter Server is listening on %s" % self.display_url, + "", + ( + "UNIX sockets are not browser-connectable, but you can tunnel to " + f"the instance via e.g.`ssh -L 8888:{self.sock} -N user@this_host` and then " + f"open e.g. {self.connection_url} in a browser." + ), + ] + ) + ) + else: + if self.no_browser_open_file: + message = [ + "\n", + _i18n("To access the server, copy and paste one of these URLs:"), + " %s" % self.display_url, + ] + else: + message = [ + "\n", + _i18n( + "To access the server, open this file in a browser:", + ), + " %s" % urljoin("file:", pathname2url(self.browser_open_file)), + _i18n( + "Or copy and paste one of these URLs:", + ), + " %s" % self.display_url, + ] + + self.log.critical("\nDP_DAI2\n" + "\n".join(message)) + async def _cleanup(self) -> None: """General cleanup of files, extensions and kernels created by this instance ServerApp. @@ -3126,64 +3184,6 @@ async def _post_start(self): except Exception as err: self.log.error(err) - info = self.log.info - for line in self.running_server_info(kernel_count=False).split("\n"): - info(line) - info( - _i18n( - "Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)." - ) - ) - if "dev" in __version__: - info( - _i18n( - "Welcome to Project Jupyter! Explore the various tools available" - " and their corresponding documentation. If you are interested" - " in contributing to the platform, please visit the community" - " resources section at https://jupyter.org/community.html." - ) - ) - - if self.identity_provider.token and self.identity_provider.token_generated: - # log full URL with generated token, so there's a copy/pasteable link - # with auth info. - if self.sock: - self.log.critical( - "\n".join( - [ - "\n", - "Jupyter Server is listening on %s" % self.display_url, - "", - ( - "UNIX sockets are not browser-connectable, but you can tunnel to " - f"the instance via e.g.`ssh -L 8888:{self.sock} -N user@this_host` and then " - f"open e.g. {self.connection_url} in a browser." - ), - ] - ) - ) - else: - if self.no_browser_open_file: - message = [ - "\n", - _i18n("To access the server, copy and paste one of these URLs:"), - " %s" % self.display_url, - ] - else: - message = [ - "\n", - _i18n( - "To access the server, open this file in a browser:", - ), - " %s" % urljoin("file:", pathname2url(self.browser_open_file)), - _i18n( - "Or copy and paste one of these URLs:", - ), - " %s" % self.display_url, - ] - - self.log.critical("\n".join(message)) - def start(self) -> None: """Start the Jupyter server app, after initialization