title: django frontend to run subprocess output to browser window
body: <p>I basically have a backend program written in perl. This program pushes some configuration onto a network device. It gives a lot of output and I want users to be able to see the program as it runs. Up to now this has been easy as I have been running from the terminal.</p>
  
  <p>Now I am trying to write a django app. I basically want a user to press submit, the browser to bring them to a new page and on this new page I want the user to see the text output of that program as it runs.</p>
  
  <p>I have managed to get the program running in the backgroound using:
  <a href="http://docs.python.org/library/subprocess.html" rel="nofollow">http://docs.python.org/library/subprocess.html</a></p>
  
  <p>Say the below is a simple request. In the response webpage I want to see the output of the program running live or at least refresh to see the latest output every few seconds (might be a workaroudn for now)</p>
  
  <pre><code>def config(request):
      builder_Config_list = Config.objects.all().order_by('-generated_date')[:100]
      if 'hostname' in request.POST and request.POST['hostname']:
          hostname = request.POST['hostname']
          command = "path/to/builder.pl --router " + hostname
          result = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
          return render_to_response('config/config.html', {'result':result, } )
  </code></pre>