"Premature end of script headers: wsgihandler.py" on usage of BytesIO()
hansmu at xs4all.nl
Mon Nov 19 16:00:42 CET 2012
On 19/11/12 14:29:13, Yasir Saleem wrote:
> Hi all,
> I am generating graphs using "cairo plot" in web2py project.
> Here I am using BytesIO() stream for generating graphs.
> Everything runs fine when I run on localhost but when I deploy
> it on apache server and then run from different machines OR
> from different browsers in same machine then the server
> becomes halt and in apache error log, I found this error
> Premature end of script headers: wsgihandler.py,
> Furthermore, it occurs only when I use BytesIO() stream for
> generating graphs. In all other cases, it run smoothly.
> Please guide me that how I should resolve this issue.
One technique is to put at the very top of the script, even
above the import statements:
print "Content-Type: text/plain\n\n"
This will cause all text output by your script to be displayed
in your browser as plain text . If you inspect it, you'll
probably find some kind of warning displayed above the HTML
headers. You'll need to find a way to not receive that warning.
It's usually best if you can actually solve the issue Python is
warning about. it that's not possible, suppressing the warning
may be your only alternative.
If you can't figure out what the message means, and Google
doesn't know either, you can post it in this forum and ask
for further guidance.
 Except if you use Internet Explorer, which will ask you
whether you want to save the document. You can either do that
and view the content with another application, or use another
browser, or change the content-type to text/html. If you do
the latter, IE will notice that the content is really plain
text, and that it is actually quite capable of displaying that.
Hope this helps,
More information about the Python-list