开发者

Redirect realtime common line output to Django HttpResponse

开发者 https://www.devze.com 2022-12-12 14:18 出处:网络
In a long run command line execution, like uncompressing a large .zip archive, how to redirect the realtime output of unzip command to browser via Django\'s HttpResponse?

In a long run command line execution, like uncompressing a large .zip archive, how to redirect the realtime output of unzip command to browser via Django's HttpResponse?

EDIT: According to paul's suggestion, I did a search and found this question h开发者_运维百科as answers to how to return a HttpResponse by using a generator.

Update HttpResponse Every Few Seconds

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


The HttpResponse constructor takes either a string or an iterable.

To trickle content down, you can make the iterable a generator.

Provided, of course, your middleware isn't interfering.

0

精彩评论

暂无评论...
验证码 换一张
取 消