Well web cgi programming in haskell like it was in c ala cgi counter.c is pretty straight forward just spew some content-type headers and content and go so I assume you mean some other kinda thing (aka some shake and bake cgi apis?)
On Jul 29, 2009 8:01 PM, "baguasquirrel" <baguas...@gmail.com> wrote:
I've never done cgi is, but I was able to do some request handlers
with Happstack... which is tantamount to building your own webserver,
but I figure the webserver was never the part that needed to scale
anyway.
It was easy enough to do request handlers with the code that Happstack
provides (and I dare say fun). Just skip their whole macid thing,
which kind of clunky and difficult. You *do* have to know a thing or
two about the HTTP protocol itself, in order for the apis to make
sense, but since you mentioned cgi I figure you know your way around.
Good luck and happy hacking.
On Jul 29, 10:33 am, Rod <rli...@gmail.com> wrote: > Is anyone looking into using Haskell for cgi...
Here's a really short program that tests FastCGI. With apache, speed
was comparable (slightly faster) to a PHP script that did the same
thing. Compile this, put the result in, say, counter.fcgi, configure your web
server to process .fcgi as fastcgi, and you're done.
import Data.IORef
import Text.Printf
import Network.FastCGI
test :: IORef Int -> CGI CGIResult
test counter = do setHeader "Content-type" "text/plain"
n <- liftIO $ readIORef counter
liftIO $ writeIORef counter (n+1)
output $ printf "Hello, world: %10d\n" n
main = do counter <- newIORef 0
runFastCGIConcurrent 4 $ test counter