code / cock / cock.mod.scm

1(module cock (serve)
2
3  (import (scheme)
4          (chicken base)
5          (chicken process signal)
6          (spiffy)
7          (utf8))
8
9  (define (eprint . xs)
10    (for-each (lambda (x) (display x (current-error-port)))
11              xs)
12    (newline (current-error-port)))
13
14  (define (serve root port)
15    (set-signal-handler! signal/int
16                         (lambda _
17                           (eprint "stopping server")
18                           (exit)))
19    (eprint "Starting web server in " root "...")
20    (eprint "Served at http://localhost:" port)
21    (eprint "[Ctrl-c to stop]")
22    (parameterize ((server-port port)
23                   (root-path root))
24      (start-server))))