Name: Anonymous 2009-06-06 20:43
Test.hs
$ ghc --make Test
$ ./Test
Test: user error (FCGX_Accept failed with error code: -88)
Maybe I'll just stick with CGI... how much more resources does plain CGI really take?
module Main where
import Control.Monad (liftM)
import Data.Maybe (fromMaybe)
import Network.FastCGI
import Text.XHtml.Strict
hello :: Int -> Html
hello 0 = h1 << "Welcome"
+++ p << "This is the first time I've seen you."
hello c = h1 << "Welcome back!"
+++ p << ("I have seen you " ++ show c ++ case c of
1 -> " time before"
_ -> " times before")
page :: String -> Html -> Html
page t b = header << thetitle << t +++ body << b
cgiMain :: CGI CGIResult
cgiMain = do
c <- liftM (fromMaybe 0) $ readCookie "mycookie"
setCookie (newCookie "mycookie" $ show (c + 1))
output $ showHtml $ page "Cookie example" $ hello c
main :: IO ()
main = runFastCGI $ handleErrors cgiMain$ ghc --make Test
$ ./Test
Test: user error (FCGX_Accept failed with error code: -88)
Maybe I'll just stick with CGI... how much more resources does plain CGI really take?