Welcome to the CHICKEN Scheme pasting service

minimal node-like spiffy added by caolanm on Fri Mar 9 16:23:10 2018

(use spiffy intarweb)

(define msg "hello\n")

;; this function is like a Connect middleware from nodejs,
;; call (continue) to pass control back to spiffy
(define (handler continue)
  ;; instead of being passed request and response as arguments
  ;; spiffy uses (current-request) and (current-response)
  (let ((res (update-response
              (current-response)
              code: 200
              headers: (headers `((content-length ,(string-length msg)))))))
    ;; write the response head - like response.writeHead() in nodejs
    (write-response res)
    ;; write the response body - like response.write() in nodejs
    (display msg (response-port (current-response)))
    ;; complete the response - like response.end() in nodejs
    (finish-response-body res)))

;; this allows you to host multiple sites at different subdomains etc.
;; like nginx or similar - to use it like node, just set up a wildcard
(vhost-map
  `((".*" . ,handler)))

;; like Server.listen() in nodejs
(start-server)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which backend storage does qwiki use?
Visually impaired? Let me spell it for you (wav file) download WAV