Launch Jupyter server extensions as Jupyter applications.
This is an experimental library for making applications out of Jupyter server extensions.
The following describes the pattern for writing a jupyter server extension that also works as a standalone application.
- Subclass the
ExtensionHandler
to handler API requests. This handler points thestatic_url
to namespaced endpoints under thestatic
url pattern.
from jupyter_server_extension.handler import JupyterExtensionHandler
class MyExtensionHandler(ExtensionHandler):
def get(self):
self.render_template("index.html")
- Subclass the
ExtensionApp
and add handlers.
from traitlets import Unicode
from jupyter_server_extension.application import ExtensionApp
class MyExtensionApp(ExtensionApp):
name = Unicode("my_extension")
static_paths = List(
Unicode("/path/to/static/dir/"),
help="""List of places to file static served files."""
)
def initialize_handlers(self):
self.handlers = []
self.handlers.append(
(r'/myextension', MyExtensionHandler)
)
# `launch_instance` method offers an entry point to start the server and application.
main = MyExtensionApp.launch_instance
# `load_jupyter_server_extension` method allows extension to be appended to already running server.
load_jupyter_server_extension = MyExtensionApp.load_jupyter_server_extension