user1027169
user1027169

Reputation: 2887

Accessing IPython command line from node.js and websockets

How would I go about creating a web app using node.js (Express.js) that can access the python or ipython REPL command line? Essentially I would like to have something like the IPython Notebook, but integrated into a node.js web application. I was also thinking about using websockets for low-latency, two-way communication between the app and the python instance on the server.

Upvotes: 3

Views: 1670

Answers (1)

Matt
Matt

Reputation: 27843

Use ZMQ node binding, and talk directly to the kernel using same protocol than IPython, if you want IPython notebook for node you can create a node kernle (need to be updated for last protocol version). IPython webserver already have websocket and Emacs EIN alredy use it to speek to server through websocket.

[Edit]

Some clarification after comments. About the notebook, at first order when you open the notebook web app 3 component are involved.

  • The Kernel (K) -- IPython kernel in our case, but can be IJulia, IHaskell...
  • The Server (S) -- Tornado in our case
  • The Client (C) -- Html/Js frontend for notebook

(K) talk to (S) using ZMQ. (S) act as a bridge that doe ZMQ<->Websocket translation (C) Talk to S through websocket.

What goes on the wire on ZMQ and Websocket is language agnostic, so you don't care of the language of (K), (S) or (C). ZMQ and Websocket have a high change of not using the same transport, not using the same interface/ip, and not using the same port.

Upvotes: 2

Related Questions