Network.CGI, (embedded) graphics

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Wed Nov 12 17:08:06 EST 2003


I'd like to embed pictures (.png) in a CGI-generated output.
This doesn't seem to fit directly into ghc's Network.CGI setting.
(Not entirely ghc's fault, of course :-)

By the html definition, including a picture seems to require an 
indirection. But I don't want to expose a static address,
so I am thinking of something like <IMG SRC="Get.cgi?identifier">

But this can't be done with ghc's CGI library (it assumes that text/html 
is output). So the library should export some more of its functions.
(Yes, I can easily patch this in a copy of the source code
http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/libraries/network/Network/CGI.hs?rev=1.5


Ideally, I am thinking of

class Picture a where picture :: a -> IO [ Byte ]

and I want to call Get.cgi with argument `urlencoded (show a)'.
The underlying program should then emit the byte stream
(from scratch, or from a cache). But then it would need
to do `read (urldecode input)' and this would require to
transmit a representation of the type as well.

Any ideas?

BTW, my application would be drawings of finite automata
(which can be nicely done by dot/neato),
in order to make this a bit more friendly to the eye:
http://elearning.htwk-leipzig.de/~autotool/cgi-bin/Face.cgi
(test account: matrikel 318, passwort guest,
then check problem Determine-D-Quiz)
-- 
-- Johannes Waldmann,  Tel/Fax: (0341) 3076 6479 / 6480 --
------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------




More information about the Haskell mailing list