how to show mime data using python cgi in windows+apache -
i met problem while using python(2.6) cgi show mime data in windows(apache). example, show image, here code: image.py
#!e:/program files/python26/python.exe # -*- coding: utf-8 -*- data = open('logo.png','rb').read() print 'content-type:image/png;content-disposition:attachment;filename=logo.png\n' print data
but dose not work in windows(xp or 7)+apache or iis. (i try write these code in diferent way, , try other file format, jpg , rar, no correct output, output data seems disorder in begining lines.)
and test these code in linux+apache, , ok!
#!/usr/bin/env python # -*- coding: utf-8 -*- data = open('logo.png','rb').read() print 'content-type:image/png;content-disposition:attachment;filename=logo.png\n' print data
i feel confused why not work in windows. give me , advice?
one newline between each header. 2 newlines between headers , body. , watch line endings.
print 'content-type:image/png' print 'content-disposition:attachment;filename=logo.png' print
Comments
Post a Comment