[Answered ]-Django frontend to run subprocess output to browser window


You can read the output of the subprocess like so…

pipe = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
result = pipe.stdout.read() # this is the output of the process
return render_to_response('config/config.html', {'result': result})

However, you will only be able to see the result after the process has finished. If you want to see the output as the program runs, that will be a bit tougher. I suppose it could be accomplished by putting the subprocess call into a separate process or thread, having the process write to a file or message queue, and then reading from that file in your view.

Leave a comment