Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python cgitb is not functioning through a browser

I can't seem to get the python module cgitb to output the stack trace in a browser. I have no problems in a shell environment. I'm running Centos 6 with python 2.6.

Here is an example simple code that I am using:

import cgitb; cgitb.enable()

print "Content-type: text/html"
print

print 1/0

I get an Internal Server error instead of the printed detailed report. I have tried different error types, different browsers, etc.

When I don't have an error, of course python works fine. It will print the error in a shell fine. The point of cgitb is to print the error instead of returning an "Internal Server Error" in the browser for most error exceptions. Basically I'm just trying to get cgitb to work in a browser environment.

Any Suggestions?

like image 790
Jonathan Avatar asked Oct 03 '13 02:10

Jonathan


1 Answers

Okay, I got my problem fixed and the OP brought me to it: Even tho cgitb will output HTML by default, it will not output a header! And Apache does not like that and might give you some stupid error like:

<...blablabla>: Response header name '<!--' contains invalid characters, aborting request

It indicates, that Apache was still working its way through the headers when it already encountered some HTML. Look at what the OP prints before the error is triggered. That is a header and you need that. Including the empty line.

like image 97
Chris Avatar answered Nov 02 '22 22:11

Chris