[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] RE: [Axiom-developer] Simple web server code for GCLfor Wind

From: Page, Bill
Subject: [Gcl-devel] RE: [Axiom-developer] Simple web server code for GCLfor Windows
Date: Tue, 3 May 2005 16:21:03 -0400


You are right. The simple GCL web server program that you
wrote is working on both linux and Windows. Great!

On Tuesday, May 03, 2005 9:56 AM Camm Maguire wrote:

> What this will send to the gcl function 'foo' is 'get /dir'
> #'foo must find a file or directory by that name to produce
> output, which I'm guessing does not exist on your system.
> You can add a diagnostic like: 

(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~%" (namestring l)))))
    (close s))

> You can also do 'telnet localhost 8085' and type 'get /dir'
> to see the output, which I think is likely '404' in my pseudo
> html error code example. 

Thanks. This works exactly as you claim. For example on my system


produces a list of files and


displays the web page in a browser (See Content-type above).

Just to play a little (although I know almost knowing about
lisp :) I also changed the file list to HTML format like this:

 (format s "<a href=\"~a\">~a</a> <a href=\"~a/\"> /... </a><br>~%"
   (namestring l) (namestring l) (namestring l)))

It would be nicer to make the result and the content type depend
on whether something was a directory or on the type of the file
etc instead of the syntax of the name, but I could not easily
discover how to do that in GCL. Specifically how can I tell a
directory from a file? Can anyone suggest a suitable "Getting
started in GCL" tutorial?

Anyway, it seems clear that we could use this approach to develop
a portable HyperTex browser for Axiom if we decide to go that

Bill Page.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]