[racket] Web server templates

From: Jordan Schatz (jordan at noionlabs.com)
Date: Wed Jun 6 12:57:12 EDT 2012

I'll have to look into what Jay wrote, as I didn't know it was possible and I'll
have to read the docs abit before I really understand it. 

But I've been getting around (mostly) the write code -> kill server / start
server -> test -> debug -> kill server / start server work flow by
coding/testing everything outside of the server, and then just doing integration
testing in the server. So using unit tests, creating request structures,
checking the responses from my functions etc. Now about 80% - 90% of my
coding/testing happens with the server not running.

- Jordan

On Tue, 5 Jun 2012 20:43:26 -0600, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> #lang web-server/insta
> (require xml
>          web-server/templates)
> (define i 0)
> (define-namespace-anchor here)
> (define (start req)
>   (set! i (add1 i))
>   (response/xexpr
>    (make-cdata #f #f
>                (eval #'(include-template (file "/tmp/template.html"))
>                      (namespace-anchor->namespace here)))))
> Similarly, when you use serve/servlet you normally give it a
> particular closure that will be executed with the requests, but
> there's no reason you couldn't give it:
> (lambda (req)
>  ((eval '(let () (local-require some-file) start)) req))
> And then change both of these evals to something that was sensitive to
> filesystem modification... that would be a simple library to make if
> you wanted it that would be independent of the Web server.

Posted on the users mailing list.