sunet/start-web-server

45 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
echo "Starting scsh..."
exec scsh -lm packages.scm -dm -o http-test -e main -s "$0" "$@"
!#
(define-structure http-test
(export main)
(open httpd-core
httpd-make-options
httpd-basic-handlers
cgi-server
let-opt
scsh
scheme)
(begin
(define (main args)
(let ((port (string->number (:optional (cdr args) "8080"))))
(if port
(begin
(format #t "Web-Server is now running on port ~d...~%" port)
(http port))
(format #t "Usage: ~a [port]~%~a~%" (car args) args))))
(define (http port)
(cond ((zero? (user-uid))
(set-gid -2) ; Should be (set-uid (->uid "nobody"))
(set-uid -2))) ; but NeXTSTEP loses.
(httpd (with-port port
(with-root-directory (absolute-file-name "./web-server/root")
(with-simultaneous-requests 23
(with-syslog? #t
(with-logfile (absolute-file-name "./web-server/httpd.log")
(with-path-handler
(alist-path-dispatcher
(list (cons "h" (home-dir-handler "public_html"))
(cons "cgi-bin"
(cgi-handler (absolute-file-name
"./web-server/root/cgi-bin"))))
(rooted-file-or-directory-handler
(absolute-file-name "./web-server/root/htdocs") ""))))))))))
))
;; EOF