;;; Scheme Underground Web Server -*- Scheme -*- ;;; Olin Shivers ;;; This file contains a few example top-level path-handlers and ;;; other useful fragments. ;;; - /h// => serve from ~user/public_html. ;;; - /seval You may POST Scheme code to this URL, and receive the output. ;;; - Otherwise, serve files from the standard HTTP demon repository. (define ph1 (alist-path-dispatcher `(("h" . ,(home-dir-handler "public_html")) ("seval" . ,seval-handler) ("cgi-bin" . ,(cgi-handler "/usr/local/etc/httpd/cgi-bin"))) (rooted-file-handler "/usr/local/etc/httpd/htdocs"))) ;;; Do a rough approximation of NCSA httpd server semantics: ;;; - /~shivers/... serves file ~shivers/public_html/... ;;; - /cgi-bin/ passes control to script ;;; /usr/local/etc/httpd/cgi-bin/ ;;; - Otherwise, just serve files out of the standard directory. (define ph2 (alist-path-dispatcher `(("cgi-bin" . ,(cgi-handler "/usr/local/etc/httpd/cgi-bin"))) (tilde-home-dir-handler "public_html" (rooted-file-handler "/usr/local/etc/httpd/htdocs")))) ;;; Greatest hits path handler. (define ph3 (alist-path-dispatcher `(("h" . ,(home-dir-handler "public_html")) ("seval" . ,seval-handler) ("cgi-bin" . ,(cgi-handler "/usr/local/etc/httpd/cgi-bin"))) (tilde-home-dir-handler "public_html" (rooted-file-handler "/usr/local/etc/httpd/htdocs")))) ;;; Crank up a server on port 8001, first resetting our identity to ;;; user "nobody". Initialise the request-invariant part of the CGI ;;; env before starting. (define (httpd1) (set-gid (->uid "nobody")) (set-uid (->gid "nobody")) (initialise-request-invariant-cgi-env) (httpd (make-httpd-options with-path-handler ph with-port 8001 with-root-directory "/usr/local/etc/httpd/htdocs")))