[racket] Racket Web App

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Aug 30 15:10:22 EDT 2011

You should look at the #:extra-files-paths argument to serve/servlet
to specify where to find static files.

Jay

On Tue, Aug 30, 2011 at 12:49 PM, Stees, Micheal T.
<MSTEES at monmouthcollege.edu> wrote:
> Hello all,
>
> I am looking into using the racket web server and related tools to develop a webpage for a school project, and I have run into the following dilemma with the trivial example I am trying.
>
> I have racket include an html template for the test site, and that html template references an external style sheet.  When I open the html file using a browser, it correctly displays the page based on the style sheet, but when I run my web app, it does not display things correctly.  Most specifically, it ignores the "background-image..." included in the style sheet.  I have included all the relevant code below.
>
> ---------------------------------------------------
> #lang racket
>
> (require web-server/servlet
>         web-server/servlet-env
>         web-server/templates)
>
> (define (start req)
>  (response/full
>  200 #"Okay"
>  (current-seconds) TEXT/HTML-MIME-TYPE
>  empty
>  (list (string->bytes/utf-8 (include-template "htdocs/base.html")))))
>
>
> (serve/servlet start
>               #:port 80
>               ;;#:listen-ip #f
>               #:servlet-path "/test")
> ----------------------------------------------------
> html file
>
> <html>
> <head>
>
> <title> HTML Sample </title>
> <link rel="stylesheet" type="text/css" href="style.css" />
> </head>
>
> <body>
> <h2>My Title </h2>
>
> This is a <b>small</b> example of HTML <p> This is a new paragraph.<p>
>
> <ol>
>
> <li> Item one
>
> <li> Item two
>
> </ol>
>
> </body>
>
> </html>
>
> ---------------------------------------------
> style sheet
>
> body {
>    color: purple;
>    background-image: url(lightning.png);
>  }
>
>
> --------------------------------------------
>
> Thank you in advance for any assistance.
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/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.