#!/path/to/lisp-interpreter ; Creates a string of HTTP headers (defun headers (lheaders) (with-output-to-string (s) (mapcar #'(lambda (x) (format s "~{~A~^: ~}~%" x)) lheaders) (terpri s))) ; returns HTML tag as string (defun tag (name contents &optional attribs) (with-output-to-string (s) (format s "<~A" (string-downcase name)) (if attribs (mapcar #'(lambda (x) (format s " ~A=\"~A\"" (first x) (second x))) attribs)) (format s ">~A" contents (string-downcase name)))) ; action! (princ (concatenate 'string (headers '( ("Content-type" "text/html") ("X-powered-by" "SillyLispProgram"))) (tag 'html (concatenate 'string (tag 'head (tag 'title "This is a test")) (tag 'body (concatenate 'string (tag 'h1 "Hello, World!") (tag 'p (concatenate 'string "This page was generated by the crazy world of " (tag 'a "Lisp" '(("href" "http://www.lisp.org/"))) "."))) '(("style" "padding:0;") ("id" "margaret-local")))))))