[Tutor] Server Error

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sun Aug 22 06:44:12 CEST 2004



On Sun, 22 Aug 2004, Ms Soo Chong wrote:

> Server error!
>
> The server encountered an internal error and was
> unable to complete your request.
>
>     Error message:
> Premature end of script headers: basic4.py
>
> If you think this is a server error, please contact
> the webmaster

[text cut]

> I don't know why I encountered the server error.
> Please advice.



Hi Shufen,


The default error message that Apache HTTPD sends us is practically
useless.  *grin*

We need to get the system to tell us more.  Put the following at the very
top of your Python program, right after the 'import cgi' statement:

###
import cgitb; cgitb.enable()
###

This enables the 'cgi traceback' module, which should show much better
debugging messages than 'Premature end of script headers'.


Devshed doesn't mention this in their tutorial only because the tutorial
was written a year before 'cgitb' became part of the Standard Library.
But now that it's widely available, let's use it.  *grin*  You can read
more about 'cgitb' here:

    http://www.python.org/doc/lib/module-cgitb.html


It'll also help if we can see the contents of 'basic4.py': can you post it
up on the list?


Good luck to you!



More information about the Tutor mailing list