FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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'
Related topics
Does frihost still support Python for CGI programming
Python beginners help!
Python CGI work with FRIHOST
Problem with python cgi - does Python CGI work?
Python support for MySQL
Python via CGI - A personal triumph
Python via CGI - A personal triumph
Python Support ???
Is there a Python Hello World using Apache?
I find python is still not as popular as perl
I find python is still not as popular as perl
Python, CGI and CSS
Python CGI script 500 error
Tutorial needed for python cgi
Reply to topic    Frihost Forum Index -> Scripting -> Others

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