Redirect general real-time shared output to Django HttpResponse

In the long run, command line execution, for example, unloading a large .zip archive, how to redirect real-time output of unzip commands to the browser via Django HttpResponse?

EDIT: As Paul suggested, I did a search and found that this question has answers to the question of how to return HttpResponse using a generator.

Refresh HttpResponse every few seconds

Now the remaining problem is how to capture and create a generator from unzip output.

+4
source share
1 answer

The HttpResponse constructor accepts either a string or an iterable.

To skip the content down, you can make an iterative generator.

Unless, of course, your middleware does not interfere.

+1
source

All Articles