[racket] Problem with default-indices files in Web-Server

From: Gustavo Massaccesi (gustavo at oma.org.ar)
Date: Tue Feb 21 13:29:15 EST 2012

I wanted to make a 100% racket website (no html files), using the
standard plt-web-server.exe (version 5.2.1, Windows). I need that all
the pages are customized to each user.

So I edited the configuration-table.rkt file to include the index.rkt
in the list of default indices.

;--
;Edited File: configuration-table.rkt
( ...
 (default-host-table
   (host-table
     (default-indices "index.rkt" "index.html" "index.htm")
     ...))
 ...)
;--

For example, I use the example from
http://docs.racket-lang.org/web-server/servlet.html as "index.rkt"
(with (require web-server/http/xexpr)) in the web-root/htdoc
directory, and launched the webserver.

If I go to http://localhost/index.rkt , the example works as expected
and I see the "Hi Mom!" message.

But if I go to http://localhost/ , then I get the source code of the
"index.rkt" file, something like.
#lang racket (require web-server/managers/none) ... (...(...(...(body
(h1 "Hi Mom!")))))
but I expected to see only the "Hi Mom!" message.

Now I'm using a index.htm file with a redirection:
<meta http-equiv="REFRESH" content="1;url=/index.rkt">
so the problem is almost solved.

But I don't know if there is a better solution. Another problem is
that the source code of the .rkt files may have some secret info that
the users should not see (this is not my case).

Gustavo

Posted on the users mailing list.