unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: romel@lavabit.com
To: romel@lavabit.com
Cc: guile-user@gnu.org
Subject: Re: Serving files with guile web server
Date: Thu, 17 Mar 2011 10:55:29 -0400 (EDT)	[thread overview]
Message-ID: <58164.187.147.43.113.1300373729.squirrel@lavabit.com> (raw)
In-Reply-To: <9838.187.147.43.113.1300318403.squirrel@lavabit.com>

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
>
>
>
>
>






  reply	other threads:[~2011-03-17 14:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16 23:33 Serving files with guile web server romel
2011-03-17 14:55 ` romel [this message]
2011-03-19  2:20   ` Neil Jerram
2011-03-19 16:47     ` romel
2011-03-19 18:17       ` Neil Jerram
2011-03-19 22:23         ` romel
2011-03-31 14:44       ` Andy Wingo
2011-03-22  8:51     ` Thien-Thi Nguyen
2011-03-31 14:23       ` Andy Wingo
2011-03-31 15:09         ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58164.187.147.43.113.1300373729.squirrel@lavabit.com \
    --to=romel@lavabit.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).