[racket] usage of plt-web-server command

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Aug 31 22:29:52 EDT 2012

On Fri, Aug 31, 2012 at 11:49 AM, J G Cho <gcho at fundingmatters.com> wrote:
> Near the end of 3.9 Soft State section found on
> http://docs.racket-lang.org/web-server/stateless.html?q=%23%3Aquit&q=rackunit&q=commandline&q=substring&q=dispatch-rules&q=response/full#(part._stateless-example)
>
> #lang web-server
>
> (provide interface-version start)
> (define interface-version 'stateless)
>
> (define softie
>   (soft-state
>    (printf "Doing a long computation...\n")
>    (sleep 1)))
>
> (define (start req)
>   (soft-state-ref softie)
>   (printf "Done\n")
>   (start
>    (send/suspend
>     (lambda (k-url)
>       (response/xexpr
>        `(html (body (a ([href ,k-url]) "Done"))))))))
>
>
> $ plt-web-server -p 8080
> Doing a long computation...
> Done
> Done
> Done
> Done
>
> How does the above command know that it's supposed to execute the code
> above it? Is there some convention for this magic to happen?

The idea here is that you start the server and then go to the site
four times and you'd expect to see that as the output. (Notice that
"Doing a long computation..." only prints once.)

plt-web-server just starts the server... you would need to put the
servlet in the correct directory and then go to the URL.

Jay

>
> jGc
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.