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