The picoLisp built-in web server follows specific url conventions. Sometimes, it is useful to:
The following code shows a sample web server which servers files from @public_html/ directory (relative to picoLisp home, which is not a problem as you can always create a symlink), e.g. http://localhost:8080/index.html is served from @public_html/index.html file.
(load "ext.l" "lib/http.l") (de rewriteUrl (U) (chop (pack "public_html/" U)) ) # I'd recommend the following version of 'rewriteUrl'. # It avoids the 'chop' following a 'pack' by using a constant # pre-chopped "public..". # # (de rewriteUrl (U) # (append '`(chop "public_html/") (chop U)) ) (patch http '(if (<> *ConId *SesId) @X) (append '(if (<> *ConId *SesId)) (list (car @X)) (list '(setq @U (rewriteUrl @U))) (cdr @X) ) ) (redef http @ (off *HtVars) (pass http) ) (redef _htSet @ (push '*HtVars (cons (pack (next)) (next))) ) (allowed (&qrlog: can't exec uot;public_html/") "@start") (de start () (html 0 "Hello" NIL NIL "Hello World!" ) ) (server 8080 "@start")
Note that @start is never called but it could be if we used a more sophisticated rewriting function.
ToDo SSI
This page is linked from: picoLisp
Revisions: View source XHTMLV | RSSV
picoWiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively