Image by dpicker via Flickr
Here is a version of cl-http (the Common Lisp Hypermedia Server) for downloading (link), that runs on Mandriva 2006 with cumcl-18b.linux.glibc2 installed. As you probably won’t want to install this version of Mandriva on your computer I’ve created a Virtual Appliance (link), that you can download and run in VMware Player.
Mandriva 2006, is an ideal platform for small lisp projects and integrates nicely into Windows via the Openssh interface which allows applications to log into a remote machine and execute commands. I always install andLinux on my dos box because then the Xming X server is set up automatically and can be accessed from the Mandriva Virtual Machine. I just set my DISPLAY variable to the address of the Xming X server which is usually 192.168.11.1:0.0. Then when a command is executed on the Mandriva Virtual Machine using ssh (plink on windows), the Xming server is chosen for graphics output by default.
Once you’ve booted Mandiva and started iceWM and the cl-http server, just start Firefox and you’ll be presented with a start page from which you can access the documentation. To start the iceWM you’ll need to login as “plateau” with password “toor” and type startx at the shell prompt. When iceWM has started then open a shell by clicking on the terminal button in the bottom menu bar, and type in cl-http. Firefox can be started by clicking on the browser button.
The root directory for cl-http is “/usr/local/cl-http-70-23”. The patches I downloaded with this version have already been applied. One patch was rejected so I fixed the lisp code by hand. To compile cl-http just do the following:
> cd /usr/local/cl-http-70-23
> lisp < cmucl/start.lisp
At the end of this post you’ll find some example code. With luck, I’ll post some more examples about creating dynamic web pages within the next few weeks.
If you want to launch applications using ssh (plink) then you will need to log into the Mandriva Virtual Machine as “root”, password “toor”, and run ifconfig to find out what the IP address of the Virtual Machine is. Then commands can be executed as follows:
plink 192.168.86.128 -l plateau -pw toor xterm -fn 12×24
Where 192.168.86.128 is the IP address I obtained by executing ifconfig, plateau is the name of the remote account and toor is the password. Don’t forget to set the DISPLAY variable for user “plateau” to point to the Xming server.
This version of cl-http has not given me any problems but then I only created an interface to the Wordnet Lexicon which works fine.
Just for reference here are the important links, user names and passwords mentioned in this post:
- user: “root”, password “toor”
- user: “plateau”, password “toor”
- cl-http-79-23 source code: (link)
- virtual machine: (link)
Related articles
- Mandriva forks into Mageia Linux (linuxfordevices.com)
- Developers Fork Mandriva Linux, Creating Mageia (linux.slashdot.org)
- Welcome Mageia! (nowwhatthe.blogspot.com)
- Common LISP Hypermedia Server (cl-http.org:8001)
- Practical: An HTML Generation Library, the Compiler (gigamonkeys.com)
- WCF Web APIs, HTTP your way (codebetter.com)
- How I Can do web programming with Lisp or Scheme? – Stack Overflow (stackoverflow.com)
- History: Applications that were developed on the Symbolics Lisp Machine (lispm.dyndns.org)
Example 1
;;; exporting computed URLs. A. Ritz, 17 April 2001. Example 1 ;;; This example shows how to write a computed url that displays text from a file. ;;; This is probably the simplist web page that you will ever write. ;;; Two functions are provided for displaying text from a file. The first ;;; function calls lisp functions to open and iteratively read and display the ;;; contents of the file. The second function uses the run-program feature and the unix ;;; command cat. ;;; example of the preformated text, <pre>, tag. (defun Display-File1 (filename stream) (setq a (open filename)) (loop (setq str (read-line a nil)) (when (not str) (return)) (write-string "<pre>" stream) (write-string str stream) (write-string "<\pre>" stream) ) ) ;;; example of the preformatted text, <pre>, tag. (defun Display-File2 (str stream) (write-string "<pre>" stream) (run-program "cat" (list str) :output stream) (write-string "<\pre>" stream) ) ;;; example of the paragraph, <p>, tag. (defun write-paragraph (str stream) (write-string "<p>" stream) (write-string str stream) (write-string "</p>" stream) ) ;;; a horizontal rule (defun hr (stream) (write-string "<HR>") ) ;;; write the HTML for the document body. (defun Document-Body (str stream) (html:with-document-body (:stream stream) (write-paragraph str stream) (hr stream); (Display-File1 "test.txt" stream) (hr stream); (Display-File2 "test.txt" stream) (hr stream); ) ) ;;; write the HTML for the whole document. (defun Document (str stream) (html:with-html-document (:stream stream) (html:with-document-preamble (:stream stream) (html:declare-title str :stream stream) ) (Document-Body "Testing export of computed url" stream) ) ) ;;; Function Document outputs the following HTML. ;;; <HTML> ;;; <HEAD> ;;; <TITLE></TITLE> ;;; </HEAD> ;;; <BODY> ;;; The HTML output by function Document-Body. ;;; </BODY> ;;; </HTML> ;;; Write the web page (defmethod write-test-page ((url url:http-url) stream) (http:with-successful-response (stream :html :cache-control (url:response-cache-control-directives url) :content-language (url:languages url) ) (Document "Test Page" stream) ) ) ;;; export the url (http:export-url #u"/cl-http/test.html" :computed :response-function #'write-test-page :public t :language :en) ;;; Function index ;;; ;;; http:with-successful-response ;;; html:with-html-document ;;; html:with-document-preamble ;;; html:declare-title ;;; html:with-document-body ;;; http:export-url
Filed under: web servers | Leave a Comment »
