In this example, the client receives an HTML+ page that the server computes by listing a remote directory and repackaging the file names in a friendlier format. Below, we see the Common LISP definition for the response function that is invoked when a client sends the server a GET for the computed URL.
;; Export the computed URL and provide its response function. (export-url "http://clinton.ai.mit.edu/radio-addresses.html" :html-computed #'compute-clinton-audio-page) ;; Writes HTML+ directly to the client over STREAM, which is a live ;; HTTP connection to the client. (defmethod compute-clinton-audio-page ((url url:http-computed-url) stream) (flet ;; Abstract the internal function that writes an entry. ((write-pathname (pathname stream) (let ((url (url:pathname-ftp-url-string pathname)) (friendly-date (uu-radio-address-anchor-date pathname))) (when friendly-date ;; Encapsulate text within an enumeration entry. (html+:enumerating-item (stream) ;; Change the text style to bold. (html+:with-rendition (:bold :stream stream) ;; Write an HTML+ anchor spec using the friendly name. (html+:note-anchor friendly-date :reference url :stream stream))))))) ;; Main body of method. (let ((directory-list (www-utils:ftp-directory-info *saturday-radio-addresses-audio-directory* "anonymous" (www-utils:user-mail-address)))) (if directory-list ;; Inform the client that we're winning and returning HTML+. (with-successful-response (stream :html) ;; Provide the header info that goes in the HTML+. (html+:with-document-preamble (:stream stream) (html+:declare-base-reference url :stream stream) (html+:declare-title "Saturday Radio Addresses" :stream stream)) ;; Use the body environment. (html+:with-document-body (:stream stream) (html+:with-section-heading ((html+:image "http://clinton.ai.mit.edu/icons/sound-icon.xbm" "The President's Saturday Radio Addresses to the Nation" :stream nil)) (html+:new-paragraph :stream stream) ;; Provide the instructions for the WWW page. (write-string "By clicking on a date, you can listen to the audio for a Saturday radio address by President Clinton." stream) (html+:horizontal-line :stream stream) (html+:new-paragraph :stream stream) ;; Enter an environment for enumerating items. (html+:with-enumeration (stream :itemize) ;; Map over files and write them as bullets. (loop for (pathname) in directory-list do (write-pathname pathname stream)))))) ;; Signal that the server cannot connect to the remote host. (error "Unable to connect to UU.NET to get file list.")))))