(defun foo (s) 
  (let* ((get (read s nil 'eof)) 
         (fn (and (eq get 'get) (string-downcase (read s nil 'eof))))
         (fn (when (probe-file fn) fn)))
    (format s "HTTP/1.1 ~S~%" (if fn 404 500))
    (format s "Content-type: text/html~%~%")
    (format t "get ~a fn ~a~%" get fn)
    (when fn
      (if (pathname-name (pathname fn))
          (with-open-file (q fn) (si::copy-stream q s))
        (dolist (l (directory fn))
          (format s "<a href=\"~a\">~a</a> <a href=\"~a/\"> /... </a><br>~%"
	    (namestring l) (namestring l) (namestring l)))
	    ))
    (close s))
)

(defun bar (p fn) 
  (let ((s (si::socket p :server fn))) 
        (tagbody l 
                (when (si::listen s) 
                        (let ((w (si::accept s))) 
                                (foo w))) 
                (sleep 3) 
                (go l))))

(bar 8085 #'foo)

