#!/home/janweb/www/hugs/bin/runhugs +l
-- Hey, Emacs, this is -*- haskell -*-
-- Counter example Erik Meijer ([email protected])
-- cookiefied by Jan Laitenberger ([email protected])
module Main (main) where
import CGI
import Maybe(fromMaybe)
main :: IO ()
main = wrapper counter
counter :: [(Name,Value)] -> IO (CgiOut HTML)
counter env =
return Content {
mime = page "Counter" []
[ h1 "Click me!", gui counterScript [submit "Count" n1] ],
cookies = [("Count", n1, "/", "Wed, 31-Dec-2004 12:00:00 GMT")]
}
where
n0 = fromMaybe "0" (lookup "Count" env)
n1 = show (read n0 + 1)
-- Edit counterScript to point to url of the "executable" of this very module.
counterScript :: String
counterScript = "http://www.janweb.net/cgi-bin/CGI/laitenbe/Counter.hs"