[racket] Racket Web App

From: Stees, Micheal T. (MSTEES at monmouthcollege.edu)
Date: Tue Aug 30 19:21:46 EDT 2011

I looked at the example posted in the documentation that goes something like this:

#lang racket

(require web-server/servlet
         web-server/servlet-env
         web-server/templates)

(define (start req)
 (response/xexpr
   `(html (head (title "Hello world!"))
          
          (body  "Hey out there!"))))


(serve/servlet start
               ;;#:port 80
               ;;#:listen-ip #f
               ;;#:servlet-path "/test"
               #:extra-files-paths
               (list 
			(build-path "C:/Users/howboutno5/Documents/Summer/test/htdocs/style.css")))

-------------------------------------------
However the style sheet does not appear to be loading at all.  The directory that the style sheet is in, is one below the location of the .rkt file if that makes any difference.
________________________________________
From: Jay McCarthy [jay.mccarthy at gmail.com]
Sent: Tuesday, August 30, 2011 2:10 PM
To: Stees, Micheal T.
Cc: users at racket-lang.org
Subject: Re: [racket] Racket Web App

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.