[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Serving files with guile web server
From: |
romel |
Subject: |
Re: Serving files with guile web server |
Date: |
Thu, 17 Mar 2011 10:55:29 -0400 (EDT) |
User-agent: |
SquirrelMail/1.4.13 |
I gave a second read to the manual and found:
"The handler should return two values: the response, as a <response>
record from (web response), and the response body as a string, bytevector,
or #f if not present."
If this is correct then I guess I should check the file type first and
then read the file to either create a string or a bytevector from it.
Any recommendation will be highly appreciated.
Thanks,
Romel Sandoval
> Hi,
>
> I will like to serve plain text files and images with run-server from (web
> server) module.
>
> After reading the documentation I think in something similar to:
>
> -----------------
> (define (serve-file request body)
> (let* ((path (request-path-components request))
> (file-path (public-file-path path)))
> (if (and file-path (file-exists? file-path))
> (values '((content-type . (text/plain)))
> (open-input-file file-path))
> (not-found request))))
>
> (define (file-server)
> (run-server serve-file))
> -----------------
>
> But I got:
>
> -----------------
> ERROR: In procedure scm-error:
> ERROR: unexpected body type
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,bt
>
> In module/web/server.scm:
> 291:29 1 (#<procedure 22d9480 at module/web/server.scm:283:3 ()>)
> In unknown file:
> 0 (scm-error misc-error #f "~A" ("unexpected body type") #f)
> -----------------
>
> Anybody knows how to serve text and image files from guile web server?
>
> Thanks,
> Romel Sandoval
>
>
>
>
>