guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Serving files with guile web server


From: romel
Subject: Serving files with guile web server
Date: Wed, 16 Mar 2011 19:33:23 -0400 (EDT)
User-agent: SquirrelMail/1.4.13

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]