[Tutor] Re: question

Lee Harr missive at hotmail.com
Fri Sep 10 23:16:36 CEST 2004

>Can someone please help me by going through my
>python script + html script and see if I have done
>something stupid, because I can't get it running on
>the web browser. I did used import cgitb;
>cgitb.enable() and it showed the follwing error.
>Server error!
>The server encountered an internal error and was
>unable to complete your request.
>     Error message:
>Premature end of script headers: trial1.html
>If you think this is a server error, please contact
>the webmaster
>Error 500
>     localhost
>     Fri 10 Sep 2004 15:57:51 EST
>     Apache/2.0.40 (Red Hat Linux)

I made a couple of changes and it gets as far as the
database queries before bombing out...

fp=open("/var/www/html/sf/frame.html", "r")
fp=open("trial1.html", "r")

    print"""<FORM METHOD="POST" ACTION="/cgi-bin/sf/trial1.py">
    print"""<FORM METHOD="POST" ACTION="trial1.py">

Just to make it point at the right places...

How are you calling the script?
(in other words, should you be calling trial1.py and
not trying to load -- or force python to process -- trial1.html ?)

The error message you are getting looks more like a problem
with the server being misconfigured ...

Try to get the most basic script running first ("hello world")
before you start adding in other things.

I used a twisted webserver to run the script ...


acgi.rpy        trial1.html     trial1.py

cat acgi.rpy
from twisted.web import static, twcgi
class PyScript(twcgi.FilteredScript):
    filter = '/usr/local/bin/python'
resource = static.File("/home/lee/python/cgi/")
resource.processors = {".py": PyScript}

mktap web --port 9999 --path /usr/home/lee/python/cgi
twistd -f web.tap

Then I accessed it as:

Add photos to your messages with MSN 8. Get 2 months FREE*. 

More information about the Tutor mailing list