main.py 859 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. from __future__ import print_function, absolute_import
  4. import json
  5. import os.path as osp
  6. from jupyterlab_server.process import which
  7. from jupyterlab_server.process_app import ProcessApp
  8. HERE = osp.dirname(osp.realpath(__file__))
  9. class NodeApp(ProcessApp):
  10. def get_command(self):
  11. """Get the command and kwargs to run.
  12. """
  13. # Run the node script with command arguments.
  14. config = dict(baseUrl=self.connection_url, token=self.token)
  15. with open(osp.join(HERE, 'config.json'), 'w') as fid:
  16. json.dump(config, fid)
  17. cmd = [which('node'),
  18. 'index.js', '--jupyter-config-data=./config.json']
  19. return cmd, dict(cwd=HERE)
  20. if __name__ == '__main__':
  21. NodeApp.launch_instance()