[Tutor] configuring web browser PP3E

James Mills prologic at shortcircuit.net.au
Thu Jan 29 04:21:33 CET 2009


On Thu, Jan 29, 2009 at 12:17 PM, bmoll70 at att.net <bmoll70 at att.net> wrote:
> yes, i'm running on Mac OS X / Unix, but i'm afraid i don't know "where" to
> change the port to 80.  i'm working with the following files straight from
> the book 'Programming Python':

You're not blind are you ? Because I am.

> cgi101.py   (here it is...)
> #!/usr/bin/python
> 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>"
> else:
>     print "<h1>Hello <i>%s</i>!</h1>" % cgi.escape(form['user'].value)
> cgi101.html (here it is...)
> <html>
> <title>Interactive Page</title>
> <body>
> <form method=GET action="cgi-bin/cgi101.py">
>     <P><B>Enter your name:</B>
>     <P><input type=text name=user>
>     <P><input type=submit>
> </form>
> </body></html>
> and webserver.py (here it is...)
> ######################################################################
> # implement HTTP web server in Python which knows how to run server
> # side CGI scripts;  serves files/scripts from current working dir;
> # python scripts must be stored in webdir\cgi-bin or webdir\htbin;
> ######################################################################
> webdir = '.'   # where your html files and cgi-bin script directory live
> port   = 80    # default http://localhost/, else use http://localhost:xxxx/

Chat the above line.

[...]

cheers
James


More information about the Tutor mailing list