CSC151.02 2003F, Class 45: CGI Scripting Admin: * Today's goal: A little fun. * Have a great Thanksgiving break! * Remember to turn in your guessing game before you leave or before 5pm tomorrow, whichever comes first. * Yes, you need to document the guessing game. * Yes, your game should give correct answers. * Yes, your game should give an answer! (Provided the preconditions are met). * Yes, your game should use divide and conquer. * Yes, I'll be amused if you write one that guesses randomly *in addition to* the one that you are supposed to write. * Expect a take-home exam tonight or tomorrow. It will be due Tuesday of hell week. * Don't expect any more homework (except for nightly readings and labs and ...). Overview: * About the Web * CGI Scripts * Sam's See-Gee-Eye Script Strategy for Scheme * Lab In order to build an interactive Web program, we need to know or figure out the following: * How to write a Web page that provides input to the server. * How to write a Scheme program that generate HTML. * How those Scheme programs can get the input from the Web page. * How to tell our Web server to run our Scheme program. * Simple mechanism for sending input to the server
How to write a Scheme program that generates HTML (string-append "" mytitle "...") * Or use a library to help. How to get Scheme programs to read the input from the Web page. * Use Sam's library (include "/home/rebelsky/Web/Scheme/webutils.scm") * Call (get-cgi-variable VARIABLE-NAME VALUE-TO-USE-IF-UNDEFINED) How to make the Web server run your Scheme program * Create a procedure called (page) that will call get-cgi-variable and generate the page. (define page (lambda () (string-append ...))) * Save your Scheme file as text. * Make your Scheme file readable to the world. chmod a+r myprogram.scm * Create a .cgi file that reads #!/bin/bash /home/rebelsky/Web/schemeweb myprogram.scm * Make that file readable and executable chmod a+r myprogram.cgi chmod a+x myprogram.cgi