about summary refs log tree commit diff stats
path: root/scratch/htmx.scm
blob: 7ffb7e72b1093925fb0cb8f1e72c82dbf6911b05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /usr/bin/env chibi-scheme

; Simple HTTP server

(import 
  (chibi)
  (chibi net http-server)
  (chibi net servlet) 
  (chibi sxml))

(define config-port 8000)

(let ((count 0))
   (run-http-server
    config-port
    (lambda (cfg request next restart)
      (set! count (+ 1 count))
      (servlet-write request 
        (sxml->xml 
          `(html
            (head
              (title "counter")) 
            (body
              (h1 "Count: ")
              (p ,count))))))))