54 lines
1.4 KiB
Scheme
Executable File
54 lines
1.4 KiB
Scheme
Executable File
#!/bin/sh
|
|
IFS=" "
|
|
exec scsh -lm ../packages.scm -dm -o http-top -e top -s "$0" "$@"
|
|
!#
|
|
|
|
;;; Scheme Underground Web Server -*- Scheme -*-
|
|
;;; Olin Shivers
|
|
|
|
;;; To compile as a heap-image:
|
|
;;; ,open http-top
|
|
;;; (dump-scsh-program top "server")
|
|
;;; then insert a #! trigger.
|
|
|
|
(define-structure http-top (export top)
|
|
(open httpd-core
|
|
httpd-make-options
|
|
cgi-server
|
|
httpd-basic-handlers
|
|
seval-handler
|
|
scsh
|
|
scheme)
|
|
(begin
|
|
|
|
;; Kitche-sink path handler.
|
|
|
|
(define ph
|
|
(alist-path-dispatcher
|
|
`(("h" . ,(home-dir-handler "public_html"))
|
|
("seval" . ,seval-handler)
|
|
("cgi-bin" . ,(cgi-handler "/usr/local/etc/httpd/cgi-bin")))
|
|
(make-path-handler
|
|
tilde-home-dir-handler-predicate
|
|
(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 (top args)
|
|
(display "We be jammin, now.\n") (force-output)
|
|
(cond ((zero? (user-uid))
|
|
(set-gid -2) ; Should be (set-uid (->uid "nobody"))
|
|
(set-uid -2))) ; but NeXTSTEP loses.
|
|
;; invariant environment is know initilialized by cgi-handler itself
|
|
;; (initialise-request-invariant-cgi-env)
|
|
(httpd (with-path-handler
|
|
ph
|
|
(with-port
|
|
8001
|
|
(with-root-directory "/usr/local/etc/httpd")))))))
|