0

I am running one shell script from django views.py. Below is the code:

def result(request):
   if request.method=="POST":
       process=subprcoess.Popen(cmd, shell=True, stdout=subprcoess.PIPE, stderr=subprcoess.PIPE, universal_newlies=True)  
       while process.poll() is None:
           print(process.communicate()[0]) 
           continue 
   return render(request, 'result.html')

Now here can able to get logs on file, instead directly need to redirect to html page.

Could anyone please help here?

Thank You.

alex
  • 2,381
  • 4
  • 23
  • 49
peter roy
  • 9
  • 2
  • This subprocess may run up to 15-20, this output needs to be on html page as subprocess progresses – peter roy Apr 07 '22 at 10:02
  • I would rather run it in separated thread and write in file, and browser would have to use JavaScript and run periodically `fetch()` to ask server for new data from file. – furas Apr 07 '22 at 17:51
  • [python - How to stream an HttpResponse with Django - Stack Overflow](https://stackoverflow.com/questions/2922874/how-to-stream-an-httpresponse-with-django) – furas Apr 07 '22 at 17:58

0 Answers0