Lisp cgi programming for the web
Download
1 / 10

Lisp CGI Programming for the Web - PowerPoint PPT Presentation


  • 161 Views
  • Uploaded on

Lisp CGI Programming for the Web. Web servers can invoke Lisp to “intelligently” create web pages on the fly. We will use the host cubist.cs.washington.edu to explore this form of programming . Common Gateway Interface.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Lisp CGI Programming for the Web' - baylee


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Lisp cgi programming for the web
Lisp CGI Programming for the Web

Web servers can invoke Lisp to “intelligently” create web pages on the fly.

We will use the host cubist.cs.washington.edu to explore this form of programming.

CSE 341, S. Tanimoto Lisp CGI -


Common gateway interface
Common Gateway Interface

CGI: A standard method whereby a web server can invoke another program to handle a query.

HTTP: HyperText Transfer Protocol -- a standard for information requests and responses over the Internet.

CSE 341, S. Tanimoto Lisp CGI -


Get and post
GET and POST

GET. An HTTP request method in which parameters to a query are encoded as part of the URL and made available to a CGI program via environment variables.

http://www.lispfun.org/cgi-bin/weather.lsp?day=yesterday+time=night

POST. An HTTP request method in which parameters to a query are transmitted separately and passed to the program via the standard input stream.

http://www.lispfun.org/cgi-bin/weather.lsp

CSE 341, S. Tanimoto Lisp CGI -


A simple cgi program
A Simple CGI Program

#! /usr/local/bin/gcl.exe -f

(format t ”Content-type: text/html~%~%”)

(format t ”<html><head><title>Lispy</title></head>”)

(format t ”<body><h1>Hello Web!</body></html>”)

(bye)

This assumes the server is a Unix host, and that the Lisp system is Gnu Common Lisp.

CSE 341, S. Tanimoto Lisp CGI -


Brief aside unix commands
(Brief Aside) Unix Commands

List the contents of the directory with longer descriptions:

cubist$ls -l

Descend one level in the directory hierarchy:

cubist$cd www

Ascend one level in the directory hierarchy:

cubist$cd ..

Rename a file:

cubist$mv test.lsp solution.lsp

Move a file to a child directory:

cubist$mv solution.lsp www/

CSE 341, S. Tanimoto Lisp CGI -


More unix commands
More Unix Commands

Remove (delete) a file:

cubist$rm test1.lsp

Create a new subdirectory:

cubist$mkdir new-stuff

Remove a subdirectory:

cubist$rmdir old-stuff

Execute a Lisp program from the command line:

cubist$gcl solution.lsp

cubist$./solution.lsp

provided the first line of solution.lsp is...

#! /usr/local/gcl -f

CSE 341, S. Tanimoto Lisp CGI -


More unix commands cont
More Unix Commands (cont.)

chmod stands for “change mode”.

Remove permissions to execute a file:

cubist$chmod -x test1.lsp

Give group permission to execute:

cubist$chmod g+x test1.lsp

Give read permission to all users:

cubist$chmod +r test1.lsp

Take away write permission from others:

cubist$chmod o-w test1.lsp

CSE 341, S. Tanimoto Lisp CGI -


Cgi and sessions
CGI and Sessions

HTTP is “stateless”

Meaningful interactions often require “sessions”

Session continuity is a challenge.

3 separate mechanisms support solutions:

1. Passing session ID parameters between client and server with each transfer.

2. Using “cookies” on the client to identify a user or a session.

3. Storing a session file on the server between requests from a user.

CSE 341, S. Tanimoto Lisp CGI -


Other details of cgi programming
Other Details of CGI Programming

Parameter fetching for GET and POST methods.

Printing an appropriate HTTP header.

Maintaining adequate levels of security: filtering user input and never executing it directly.

Avoiding server time-outs.

CSE 341, S. Tanimoto Lisp CGI -


Code example
Code Example

The KNOCK.LSP program carries on a dialog with the user over the web, telling “knock-knock” jokes.

It illustrates three methods for saving session state: parameter passing, client-side cookies, and server-side session files.

The code is available at:

http://cubist.cs.washington.edu/~tanimoto/knock.txt

CSE 341, S. Tanimoto Lisp CGI -


ad