[Tutor] configuring web browser PP3E

bmoll70 at att.net bmoll70 at att.net
Thu Jan 29 02:31:03 CET 2009

hi.  i'm reading 'Programming Python' and having some trouble with  
adding a web interface in chapter one. (page 72)

basically, i open the cgi101.html file in Firefox.

i enter a name and hit Submit Query:

but instead of getting the Hello "name"! page returned to me....  I  
get the error page.

import cgi
form = cgi.FieldStorage()                # parse form data
print "Content-type: text/html\n"        # hdr plus blank line
print "<title>Reply Page</title>"        # html reply page
if not form.has_key('user'):
     print "<h1>Who are you?</h1>"
     print "<h1>Hello <i>%s</i>!</h1>" % cgi.escape(form['user'].value)

the book says i might have to modify the path to my Python in the #!  
line at the top of the script file and make it executable with a  
chmod command.

i've tried many things to get this working.

also, i'm not getting anywhere with the webserver.py  file either.   
here is the error message:

Traceback (most recent call last):
   File "webserver.py", line 22, in ?
     srvrobj  = HTTPServer(srvraddr, CGIHTTPRequestHandler)
   File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/SocketServer.py", line 330, in __init__
   File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/BaseHTTPServer.py", line 100, in server_bind
   File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/SocketServer.py", line 341, in server_bind
   File "<string>", line 1, in bind
socket.error: (13, 'Permission denied')

can anyone help? 

More information about the Tutor mailing list