forked from jupyterlab/jupyterlab
/
labhubapp.py
46 lines (32 loc) · 1.31 KB
/
labhubapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# coding: utf-8
"""A JupyterHub EntryPoint that defaults to use JupyterLab"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
from jupyter_server.serverapp import ServerApp
from traitlets import default
from .labapp import LabApp
if not os.environ.get("JUPYTERHUB_SINGLEUSER_APP"):
# setting this env prior to import of jupyterhub.singleuser avoids unnecessary import of notebook
os.environ["JUPYTERHUB_SINGLEUSER_APP"] = "jupyter_server.serverapp.ServerApp"
try:
from jupyterhub.singleuser.mixins import make_singleuser_app
except ImportError:
# backward-compat with jupyterhub < 1.3
from jupyterhub.singleuser import SingleUserNotebookApp as SingleUserServerApp
else:
SingleUserServerApp = make_singleuser_app(ServerApp)
class SingleUserLabApp(SingleUserServerApp):
@default("default_url")
def _default_url(self):
return "/lab"
def find_server_extensions(self):
"""unconditionally enable jupyterlab server extension
never called if using legacy SingleUserNotebookApp
"""
super().find_server_extensions()
self.jpserver_extensions[LabApp.get_extension_package()] = True
def main(argv=None):
return SingleUserLabApp.launch_instance(argv)
if __name__ == "__main__":
main()