Web
Programming

Fall 2012
course
navigation

Sep 13

Questions?
The assignment for next week has been posted.
The plan today is to continue discussion of python CGI programming that we started last time.
There's a lot of material to explore here, and we don't have a lot of time to do so.
So: what's your pleasure?
$ node > process.stdout.write("Hello world\n"); > process.env
In class we worked on the code at http://csmarlboro.org/mahoney/class_cgi/
Here it is (with a few extra TODO comments added in):
#!/usr/bin/env python # # sample.cgi # An example of a python cgi script # with a form, put/get parameters, and # (eventually) session management with cookies. import cgi # TODO: read session cookie if available; # set session data from storage. parameters = cgi.FieldStorage() if "login" in parameters: user = " " + parameters["login"].value # TODO : run user through cgi.escape to sanitize input # TODO : update stored session with login info else: user = "" # TODO: if "logout" in get/post parameters, # modify session settings & # update stored session info # TODO: create session cookie string and print headers print "Content-Type: text/html" print # TODO: if user is logged in, modify HTML string so that # (1) form has ogout button & # (2) 'secret' content is shown. print """ <!doctype html> яю1 """ % user
http://cs.marlboro.edu/ courses/ fall2012/web/ notes/ Sep_13
last modified Thursday September 13 2012 5:44 pm EDT