main.py 824 B

1234567891011121314151617181920212223242526272829
  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
  6. from jupyterlab_server.process import which
  7. from jupyterlab_server.process_app import ProcessApp
  8. HERE = os.path.dirname(os.path.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('config.json', 'w') as fid:
  16. json.dump(config, fid)
  17. cmd = [which('node'), 'index.js', '--jupyter-config-data=./config.json']
  18. return cmd, dict(cwd=HERE)
  19. if __name__ == '__main__':
  20. NodeApp.launch_instance()