[Tutor] CGI error

Luke Paireepinart rabidpoobear at gmail.com
Sat Jul 14 05:26:39 CEST 2007


Darren Williams wrote:
>  Hi all Smile
>
> I have a Windows hosting account with lunarpages.com and am having a 
> bit of trouble with CGI. I have enabled both CGI and Python in the 
> control panel and made sure the permissions for all my CGI scripts are 
> set to both readable and executable for all users but I keep getting 
> the same 'The specified CGI application misbehaved by not returning a 
> complete set of HTTP headers' error.
>
> The script that i'm trying to execute (example_7.1.py) -
>
>
>             Code: [Download
>             <http://python-forum.org/py/code_download.php?post=&code_item=1>]
>
>    1. |#!/usr/bin/python|
>   2.
>
>    3. # Import the CGI module
>    4. import cgi
>   5.
>
>    6. # Required header that tells the browser how to render the HTML.
>    7. print "Content-Type: text/html\n\n"
>
Darren - are you sure this line is being executed?
I have a suspicion that something to do with CGI in IIS (I have no idea, 
I've never used IIS) might be calling your functions directly
and not running this module?  I'm not sure, that's sort of how it works 
in Apache - mod_python calls a specific function inside a specific module,
or something like that.
Additionally, try adding '\r\n\r\n' instead of '\n\n' because, as it's 
IIS, which is a microsoft product,
it might require the MS-style newline rather than the unix-style.
>
>   1.
>
>
>    2. # Define function to generate HTML form.
>    3. def generate_form():
>    4.     print "<HTML>\n"
>    5.     print "<HEAD>\n"
>
> [snip more code]
>
> And the server log -
>
> [snip server log]
>
> Thanks in advance for any help Smile
Sure!  Hope I helped somewhat, or at least sparked an idea.
-Luke


More information about the Tutor mailing list