summary refs log tree commit diff stats
path: root/cock.mod.scm
diff options
context:
space:
mode:
Diffstat (limited to 'cock.mod.scm')
-rw-r--r--cock.mod.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/cock.mod.scm b/cock.mod.scm new file mode 100644 index 0000000..5fc9c79 --- /dev/null +++ b/cock.mod.scm
@@ -0,0 +1,24 @@
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))))