Peter Mott wrote:
I am using:
Python 2.3.4 (#2, Nov 14 2004, 18:06:48)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
with Apache/1.3.26. The following script causes an Internal Server Error
(with nothing in the Apache error logs AFAIK):
#!/usr/local/bin/python
import logging
print "Content-type: text/html\n\n"
print "<html><head><title></title></head><body><h1>OK</h1>"""
print "</body></html>"
The same script with the import statement commented out works as expected.
Has anyone encountered this? I have googled without success.
Can't help on the specific problem, but two points:
1. You are supposed to be returning \r\n, I believe, not just
\n between lines.
2. If you want to see what is going wrong, put a try/except
around the import statement and try to write something useful
along with your results:
err = ''
try:
import logging
except Exception, ex:
err = str(ex)
print 'Content-type: test/html\r\n\r\n'
blah blah blah
print '<p>Error: %s</p>\r\n'
If you can manage to import the sys and traceback modules,
you can get a more fully formatted exception using
''.join(traceback.format_exception(*sys.exc_info() ))
-Peter