[plt-scheme] PLT Web Server

From: Emmanuel Delaborde (emmanuel.delaborde at cimex.com)
Date: Sat Jul 25 15:30:03 EDT 2009


I've just read "Continue: Web Applications in PLT Scheme"
and started modifying the blog application.

I want to add a file upload form but I got stuck...

the code generating the form is:

(form ((action ,(make-url add-image))
             (method "post")
             (enctype "multipart/form-data"))
           (input ((type "file")(name "image")))
           (input ((type "submit"))))

I am not sure how to write add-image, more precisely, I am not sure  
what type of data (extract-binding/single 'image bindings) is...
My hunch is that it is a binary stream (the file data), so I tried:

(define (add-image request)
             (define bindings (request-bindings request))
             (save-image! (extract-binding/single 'image bindings)  


(define (save-image! image-data image-name)
   (with-output-to-file (build-path (find-system-path 'home-dir)  
     (lambda () (write image-data))
     #:exists 'replace))

but this gives the following exception:

The application raised an exception with the message:

you broke the contract xexpr? on start; Not an Xexpr. Expected a  
string, symbol, number, comment, processing instruction, or list,  
given #<void>


Stack trace:

<unknown procedure> at:
   line 18, column 5, in file /Applications/PLT Scheme v4.2/collects/ 

Any idea what went wrong ?
Is there any examples online of web app written with PLT, beside the  
Continue tutorial ?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090725/e21e7d12/attachment.html>

Posted on the users mailing list.