The python CGI scripts in this folder illustrate several aspects of cgi programming, in increasing levels of sophistication. Run 'em in the http://cs.marlboro.edu/code/python/brownian/ folder. And see the source code by appending _html to the URL, e.g. random_walk.cgi_html . All three use PIL, the Python Imaging library; see http://www.pythonware.com/products/pil/ for the details. Note that this library is not installed by default with python itself. To install it on ubuntu: $ apt-get install python-imaging To install it on MacOS with macports $ port install py27-pil # for python 2.7* A number of the standard cgi python modules are used to pull the HTTP data from the environment variables and print them out in the correct HTTP header format. A good starting place for the basic docs on all this is http://wiki.python.org/moin/CgiScripts And a nice summary of python itself and its use in cgi can be found at http://www.python.org/doc/essays/ppt/sd99east/sld001.htm ------------------------------------------------------------------------ random_walk_0.cgi Generate a simple dynamic image consisting of a few lines, one of which is randomly placed. random_walk_1.cgi Generate a more complex dynamic image illustrating a 2D random walk. The color of the path also changes randomly. random_walk.cgi All the bells and whistles : Generate the same 2D random walk, but with 1) image options which can be set by the visitor in the URL, e.g. random_walk.cgi?steplength=20, and 2) cookies that remember these options so that once set, the persist for that visitor. The options which can be set are (width, height, steplength, maxsteps, colorchangeperstep). And they can be reset to their default values by passing ?default=1 in the URL. See source code for the dtails. This file also has a description of some of the debugging tricks you can use for python cgi. -------------------------------------------------------------------------- Jim Mahoney Computer Science @ Marlboro College cs.marlboro.edu Sep 2012