CSC 153 | Grinnell College | Spring, 2005 |
Computer Science Fundamentals | ||
Laboratory Exercise | ||
This laboratory exercise provides experience with the basic format of documents which you routinely find on the World-Wide Web. The lab also suggests some initial experiments regarding CGI programming, which allows a Web developer to tailor documents to an individual Web user.
The document sample.html shows several basic elements of a typical Web document
Use this link to view this document in your viewer.
Once you have this sample document in your viewer, move to the View option in your browser, and select the Page Source option. This will show you the original document sample.html, as sent by the server to your browser (and before the browser has done its formatting).
Compare the original sample.html document with what the browser displayed when you first accessed this page. Note how the browser interprets the formatting instructions in displaying the material.
Follow these steps to copy this sample lab to your account in a way that will be accessible to the World-Wide Web:
Before anything in your MathLAN account can be accessed on the Web, you must make your home directory accessible. To do this, open a terminal window and give the command
chmod 755 ~
at the prompt. (The symbol ~ stands for your home directory.)
Any materials related to the World Wide Web belong in a subdirectory of your home directory named public_html. If you have no such subdirectory, create one by giving the command
mkdir ~/public_html
in the terminal window. This directory, too, must be accessible; give the command
chmod 755 ~/public_html
to make it so.
Copy the sample program to your public_html directory in two steps: First move from your home directory to the public_html directory with the command:
cd public_htmlThen copy the file to your current directory (which is public_html) with the command:
cp ~walker/public_html/courses/153.sp05/labs/sample.html sample.html
The copy of the file will have the name sample.html .
Share your copy of sample.html with the command:
chmod 755 sample.html
Load this file into your Web browser by entering the URL:
http://www.cs.grinnell.edu/~yourusername/sample.html
Note that when you specify a URL, the Web server automatically looks in your public_html directory, so you do not need to include that directory name in what you type.
Edit this file with Emacs, trying some variations of the wording and trying some of the formatting tags described above. At the very least, change the address at the bottom of the Web page to your username and file name. Also, update the date created and last revised.
After each modification, use the reload button on your browser to check your revised version of sample.html .
Edit the file further, leaving out the initial < html > tag. Reload and describe what happens. Then reinsert this tag, and try omitting some other closing elements, reload, and describe what happens.
Change the <h3> to <h2> or <h1> or <h4>, and describe what happens in each case. Do you see any progression in style or format from <h1> to <h2> to <h3> to <h4> ?
If you are not in the right directory, type
cd ~/public_htmlto move there.
mkdir cgi-bin chmod 755 cgi-bin
cd cgi-bin
cp ~walker/public_html/cgi-bin/sample-script.cgi . cp ~walker/public_html/cgi-bin/sample-script.ss . chmod 755 sample-script.cgi chmod 755 sample-script.ssYou are now ready to view the results of your copies of these files by using the URL
http://www.cs.grinnell.edu/~yourusername/cgi-bin/sample-script.cgi
(load "sample-script.ss")Note the output received.
/usr/bin/mzscheme −−mute-bannerIdentify the difference between this interaction and a typical Scheme session.
/usr/bin/mzscheme −−load sample-script.cgi
/usr/bin/mzscheme --mute-banner --load /home/walker/public_html/cgi-bin/sample-script.ssand observe the output. Note that this runs mzscheme using the file sample-script.ss without any additional banner or prompting information.
One such cgi script is http://www.walker.cs.grinnell.edu/cgi-bin/what-i-know-script.cgi
This document is available on the World Wide Web as
http://www.walker.cs.grinnell.edu/courses/153.sp05/labs/lab-cgi-intro.html
created October 12, 1998 last revised March 7, 2005 |
![]() ![]() |
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |