(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)