From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: romel@lavabit.com Newsgroups: gmane.lisp.guile.user Subject: Re: Serving files with guile web server Date: Thu, 17 Mar 2011 10:55:29 -0400 (EDT) Message-ID: <58164.187.147.43.113.1300373729.squirrel@lavabit.com> References: <9838.187.147.43.113.1300318403.squirrel@lavabit.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1300382106 22690 80.91.229.12 (17 Mar 2011 17:15:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 17 Mar 2011 17:15:06 +0000 (UTC) Cc: guile-user@gnu.org To: romel@lavabit.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Mar 17 18:15:01 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0Gmr-0006PH-6m for guile-user@m.gmane.org; Thu, 17 Mar 2011 18:15:01 +0100 Original-Received: from localhost ([127.0.0.1]:57238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0FqQ-0005Gi-S9 for guile-user@m.gmane.org; Thu, 17 Mar 2011 12:14:39 -0400 Original-Received: from [140.186.70.92] (port=48704 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0EcE-00006Z-CN for guile-user@gnu.org; Thu, 17 Mar 2011 10:56:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0Ebv-0007V7-Aw for guile-user@gnu.org; Thu, 17 Mar 2011 10:55:36 -0400 Original-Received: from karen.lavabit.com ([72.249.41.33]:45271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0Ebv-0007Us-5G for guile-user@gnu.org; Thu, 17 Mar 2011 10:55:35 -0400 Original-Received: from a.earth.lavabit.com (a.earth.lavabit.com [192.168.111.10]) by karen.lavabit.com (Postfix) with ESMTP id ED6C811BA2F; Thu, 17 Mar 2011 09:55:33 -0500 (CDT) Original-Received: from lavabit.com (dsl-187-147-43-113-dyn.prod-infinitum.com.mx [187.147.43.113]) by lavabit.com with ESMTP id 7IJZS3N3UOVH; Thu, 17 Mar 2011 09:55:29 -0500 Original-Received: from 187.147.43.113 (SquirrelMail authenticated user romel) by lavabit.com with HTTP; Thu, 17 Mar 2011 10:55:29 -0400 (EDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=nGAK8Zy8SBzLwvw0qAdToams35ha6Bnko/9EatuAguGy94a9W5VtEb3NF6g++9F2NxpWCQ3l2+/JKAI8ImkEeU68ePpPczZ4MyXeit64xzduK6b6c6dgjlTglK9xl7BTGSgG4uolKPfvuAltB38Q5JLu0/lDNYlvVk/z6dP9/zU=; h=Message-ID:In-Reply-To:References:Date:Subject:From:To:Cc:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding; In-Reply-To: <9838.187.147.43.113.1300318403.squirrel@lavabit.com> User-Agent: SquirrelMail/1.4.13 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 72.249.41.33 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8542 Archived-At: I gave a second read to the manual and found: "The handler should return two values: the response, as a 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 (#) > 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 > > > > >