What's the right form of python interpreter?
Question: I just began to learn Python for not long and I tried to run a very simple
python CGI script.

The html code is

    
    
    <form action='cgi-bin/hello_get.py' method = 'post'>
    Name: <input type = 'text' name = 'name'> <br/>
    <input type = 'submit' value='Submit'/>
    </form>
    

and the 'hello_get.py' file is

    
    
    #!c:/Python27/python.exe 
    
    import cig, cgitb
    
    form = cgi.FieldStorage()
    
    name = form.getvalue('name')
    
    
    print "Content-type:text/html\r\n\r\n"
    print "<html>"
    print "<head>"
    print "<title>Hello - Second CGI Program</title>"
    print "</head>"
    print "<body>"
    print "<h2>Hello %s </h2> % (name)"
    print "</body>"
    print "</html>"
    

However, everytime I tried it on the browser, after I press Submit, the reply
was the whole 'hello_get.py' file. The page just show the whole content of
'hello_get.py' file. Like this <http://i.imgur.com/ogUcE0l.jpg> So where did I
go wrong? It should be very simple.I thought the form of the path of python
interpreter was wrong, but I have tried several ways and nothing worked.

Thanks!!!


Answer: Your first print line ends with a double quote instead of a single quote.
Change it to this:

    
    
    print 'Content-type:text/html\r\n\r\n'
    

EDIT After looking at an example online, that first line should be surrounded
by double quotes, so

    
    
    print "Content-type:text/html\r\n\r\n"
    

