Python - UWSGI Send File To Client (For Download)

 

First , Reference to this greate article : Graham Dumpleton: Testing a wsgi.file_wrapper implementation.

 

 

Second , Be sure that should response header first , then send your binary data to client use 'wsgi.file_wrapper':

if 'wsgi.file_wrapper' in environ:
    return environ['wsgi.file_wrapper'](filelike, block_size)
else:
    return iter(lambda: filelike.read(block_size), '')

  

 

At last , Take a look at Stackoverflow:  Returning a file to a WSGI GET request

 

 

posted @ 2013-11-04 12:41  makemelike  阅读(238)  评论(0编辑  收藏  举报