mod_python

Gerhard Häring gerhard at bigfoot.de
Wed Apr 17 19:23:21 EDT 2002


Gerhard Häring wrote in comp.lang.python:
> daniela eilers wrote in comp.lang.python:
>> hi, experts
>> currently, i'm a python beginner.
>> normal python script run with apache, no probs.
>> trying to run mod_python under apache i get the following error message:
>> 
>> premature end of script headers. 
>> 
>> there is the code of my cgi script:
>> 
>> from mod_python import apache 
>>          def handler(req): 
>>               req.content_type = "text/html" 
>>               req.send_http_header() 
>>               req.write("Hello World") 
>>               return apache.OKimport apache 
>                        ^^^^^^^^^^^^^^^^^^^^^^
> 
> Looks like here's the error. This should be simply apache.OK. Apart
> from that, your example looks exactly like the one on  from
> 
> http://www.modpython.org/live/mod_python-2.7/doc/tut-what-it-do.html
> 
> and should be ok.

Except of course you should really fix the indentation of the handler
function, which should of course start at column 0. Otherwise, your
Python script will not even compile, which you could check by
importing it.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))



More information about the Python-list mailing list