1 / 10

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 . Common Gateway Interface.

baylee
Download Presentation

Lisp CGI Programming for the Web

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 -

  2. 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 -

  3. 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 -

  4. 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 -

  5. (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 -

  6. 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 -

  7. 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 -

  8. 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 -

  9. 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 -

  10. 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 -

More Related