Disclaimer: this post describes experience of a Happstack newbie.
A very simple (but already useful!) server in Happstack may be written like this:
import Happstack.Server
import System.Environment
import Control.Monad (when)
main = do
args <- getArgs
when (length args < 2) $ error "Usage: ./HelloHTTP <a directory to serve>"
simpleHTTP nullConf $ serveDirectory EnableBrowsing ["index.htm"] (head args)
This has been pretty sufficient for my simple home page for some time, but now I want logging about who is visiting the page.
Let’s do this!
Continue reading