[PLUG] python as a cgi in Apache

Paul Heinlein heinlein at attbi.com
Thu Sep 12 13:57:49 UTC 2002


On Thu, 12 Sep 2002, Josh Orchard wrote:

> I then try to execute a simple python script: (~josh/cgi-bin/test.py)
> #!/usr/bin/python2
> 
> print '''
> Content-Type: text/html\n\n
> <html>
> <head>
> <title>Hello there </title>
> </head>
> 
> <body>
> 
>     Hello
> </body>
> </html>
> '''
> 
> 
> I get server 500 errors and the logs show:
> 
> Premature end of script headers: /home/josh/public_html/cgi-bin/test.py

I don't know much python, so I may be way off the mark -- but my hunch 
is that your script is a literal '\n\n' string, not two newlines, in 
your Content-Type description. Try this:

  print '''
  Content-Type: text/html

  <html>
  ...
  </html>
  '''

--Paul Heinlein <heinlein at attbi.com>





More information about the PLUG mailing list