Search code examples
pythonconsolecometjavascript

Javascript library for displaying Python console app output


I'm writing a simple web-based front-end for a Python console program that runs on a local machine. The interactions are extremely simple. Essentially, the web front-end needs to:

  1. Accept input from the user (through an AJAX form or something).
  2. Pass this input to the Python program and run it.
  3. Display the output of the Python console program while it is running, until it terminates.

The first two can be accomplished quite easily (though suitable AJAX library recommendations would be helpful).

Question: What Javascript library would I need to accomplish No. 3?


Remarks:

  • I am aware of packages like AJAXterm and Shellinabox, but instead of a full-shell, I just want to display the output of the Python console program; essentially I'd like a way to pipe Python's stdout to a web-page in real-time.

Solution

  • You are probably looking for a comet implementation or another server push protocol, because of the unpredictable timing of python code output. So on the server side you have a thread that is reading from your python process' stdout and pushing out the output to your client via comet.

    cometd may be your best bet for the client & server components.