diff options
author | Case Duckworth | 2023-09-08 12:28:25 -0500 |
---|---|---|
committer | Case Duckworth | 2023-09-08 12:28:25 -0500 |
commit | bc1ba43d2e23ff6674c92f4cd1ab5fb3b1a673ec (patch) | |
tree | bf7f82ceed01524e75474fc93e2f6e52eb083a15 /cock.mod.scm | |
download | cock-main.tar.gz cock-main.zip |
first commit main
Diffstat (limited to 'cock.mod.scm')
-rw-r--r-- | cock.mod.scm | 24 |
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)))) | ||