2

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.
4

1 回答 1

1

由于 python 代码输出的时间不可预测,您可能正在寻找一个彗星实现或另一个服务器推送协议。因此,在服务器端,您有一个线程正在从您的 python 进程中读取stdout并通过 comet 将输出推送到您的客户端。

Cometd可能是客户端和服务器组件的最佳选择。

于 2012-04-20T07:34:20.623 回答