main.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. from jupyterlab_server import LabServerApp, LabConfig
  4. from notebook.utils import url_path_join as ujoin
  5. import json
  6. import os
  7. from traitlets import Unicode
  8. HERE = os.path.dirname(__file__)
  9. # Turn off the Jupyter configuration system so configuration files on disk do
  10. # not affect this app. This helps this app to truly be standalone.
  11. os.environ["JUPYTER_NO_CONFIG"]="1"
  12. with open(os.path.join(HERE, 'package.json')) as fid:
  13. version = json.load(fid)['version']
  14. class ExampleApp(LabServerApp):
  15. base_url = '/foo'
  16. default_url = Unicode('/example',
  17. help='The default URL to redirect to from `/`')
  18. lab_config = LabConfig(
  19. app_name = 'JupyterLab Example App',
  20. app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
  21. app_version = version,
  22. app_url = '/example',
  23. schemas_dir = os.path.join(HERE, 'build', 'schemas'),
  24. static_dir = os.path.join(HERE, 'build'),
  25. templates_dir = os.path.join(HERE, 'templates'),
  26. themes_dir = os.path.join(HERE, 'build', 'themes'),
  27. user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
  28. workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
  29. )
  30. def start(self):
  31. settings = self.web_app.settings
  32. # By default, make terminals available.
  33. settings.setdefault('terminals_available', True)
  34. super().start()
  35. if __name__ == '__main__':
  36. ExampleApp.launch_instance()