FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How to debug Python CGI errors

 


deepak
Hello,

You might have used python as cgi and might be knowing how to debug errors on browsers, but many of them still dont use this features.

Have a look at
http://deepak.frih.net/cgi-bin/test_python.cgi

In above script, I called a function which is not defined into the script, as a result, it should raise NAME ERROR.

You could also debug you python files by importing cgitb.

Code:
import cgitb; cgitb.enable()


Happy debugging!
spam
ok, well i tried this, and not unexpectedly i have done something wrong Smile because it didn't quite work for me.. i tried it by aking a quite simple mistake in my cgi script

Code:
#!/usr/bin/python

import cgi
import cgitb; cgitb.enable()

print "Content-type: text/html\n"
print "<TITLE>frid.frih.net</TITLE>"
print "<H1>frid.frih.net<H1>"
print "<P>Hello, World!</P>


missing the last quote, but instead of debugging info i got an all too familiar 500 'Internal Server Error' message and an additional 404 not found error cos i have no error documnet thing in my .htaccess Smile

what did i do wrong!!
deepak
Because your HTTP header is wrong

use this one :
Code:
print 'Content-type: text/html\n\n'
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.