Held Tuesday, September 17, 2002
Today we begin our exploration of the CGI scripts that are used
to dynamically generate Web pages.
- As you've requested, I've put
last Friday's examples online.
- Any remaining questions on homework 2?
- If you need to reach me ...
- I'll be available after class
- I'll be in my office from about 1:30 to 2:15 today and in the MathLAN
from about 2:15 to 3:05.
- I'll check my email tonight (probably some time between 8 and 10 pm)
- The More CGI reading is not
yet available. Check after 5pm. If it's still not available, assume
that I'm not going to write it.
- Notes on CGI.
- What is CGI
- Giving input to CGI programs
- Reading input in CGI programs
- Lab: CGI.
- The World Wide Web was originally created to serve so-called static
pages, pages whose content did not change.
- Soon after the creation of the Web, page authors realized that they wanted
to be able to dynamically generate pages.
- A page might depend on input specified by the user.
- A page might depend on the output of a program.
- In these cases, the server needs to run a program to generate the page.
- The standard mechanism developed to handle these issues is called
CGI, or common gateway interface.
- The standard sequence of steps:
- The user sends a request for a page which is implemented by a CGI
- The server packages up any information the program might need and
executes the program.
- The program generates HTML (or an image or ...) and sends it back
to the server.
- The server sends it back to the browser.
- Since the program simply generates data, you can use almost any
programming language to write CGI scripts.
- How does the server know whether a file is a static page or a CGI
- Sometimes, by its suffix (
.cgi represents CGI scripts).
- Sometimes, by its URL (things in
cgi-bin are CGI scripts).
- Sometimes, by custom server configuration.
- In MathLAN, anything that ends in
.cgi is a CGI script.
- Unfortunately, getting the server to call your program is sometimes
a little bit harder than you'd like.
- I've set up some helper files to make life easier.
- Your Scheme program must include a
that returns a string that represents an HTML page.
- You may have written a similar procedure in the
- Your CGI script should have the following form
/home/rebelsky/bin/schemeweb is the helper program
I've set up to run Scheme-based CGI scripts.
- How does a CGI program get values from the user?
- Using a special kind of HTML called a form.
- A form typically has the form
<form method="get" action="cgi-script">
<input type="text" name="variable-name">
<input type="submit" value="text-on-button">
- You can use the
extract-binding/single procedure to
extract the value associated with a variable name from a form.
- For example
(extract-binding/single 'color (get-bindings)))
Thursday, 29 August 2002
Tuesday, 17 September 2002
- Filled in some more details.