def getfile(uri, environ, start_response):
if len(uri) <= 1:
start_response('404 Not Found',[('Content-Type', 'application/json; charset=utf-8')])
return ['no file name, please import like http://ip:port/download/filename'.encode('utf-8')]
filebasename = uri[1]
print('filebasename:',filebasename)
filepath = 'D:\\code_lib\\filedownload\\download\\'
filename = filepath + filebasename
if os.path.exists(filename) == False:
start_response('404 Not Found',[('Content-Type', 'application/json; charset=utf-8')])
return ['filename error, please check filename!'.encode('utf-8')]
try:
hdr_content_type_stream = ('Content-Type', 'application/octet-stream; charset=utf-8')
hdr_content_ty