[plt-scheme] pretty URLs

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Sun Dec 28 17:37:42 EST 2008

> (serve/servlet start #:launch-browser #f #:port 80 #:servlet-path  
> (string->path "/code.ss"))
> --->
> Servlet (@ /servlets/code.ss) didn't load:
> build-path: absolute path "/code.ss" cannot be added to a path

The #:servlet-path argument refers to the local URL of the servlet. It  
should be a string rather than a path object. This is different to the  
#:extra-files-paths and #:mime-types-path arguments, which refer to  
paths on your local filesystem.

Say you have a servlet function that you want on the URL "http://localhost:8000/foo 
". You also have a directory called "htdocs/stylesheets" containing a  
bunch of CSS files. You might write your call to serve/servlet as  

      #:port              8000
      #:servlet-path      "/foo"
      #:extra-files-paths (list (build-path "htdocs")))

The web server sends all requests to "/foo" to your servlet and serves  
all other URLs out of your static content directory:

     http://localhost:8000/foo                    ==>    servlet
     http://localhost:8000/stylesheets/bar.css    ==>    htdocs/ 

Hope this helps,

-- Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081228/0287fd60/attachment.html>

Posted on the users mailing list.