-- with gracious thanks to mightybyte:
-- http://softwaresimply.blogspot.com/2008_02_01_archive.html
module Main where
import Happstack.Server hiding (port)
import Happstack.State
import Controller
import System.Environment
import StateVersions.AppState1
import Happstack.Server.Helpers
main :: IO ()
main = do
args <- getArgs
case args of
[port, dynamicTemplateReload', allowStressTests'] -> do
let p = read port
allowStressTests = read allowStressTests'
dynamicTemplateReload = read dynamicTemplateReload'
tDirGroups <- getTemplateGroups
smartserver (Conf p Nothing) "happs-tutorial"
(controller tDirGroups dynamicTemplateReload allowStressTests)
stateProxy
_ -> putStrLn "usage example: happs-tutorial 5001 True True (starts the app on port 5001, \
\templates reload dynamically on every request, allows stress tests)"
runInGhci :: IO ()
runInGhci = do
putStrLn $ "happs tutorial running in ghci. \n" ++
"exit :q ghci completely and reenter ghci, before restarting."
tDirGroups <- getTemplateGroups
smartserver (Conf 5001 Nothing) "happs-tutorial" (controller tDirGroups True True) stateProxy
stateProxy :: Proxy AppState
stateProxy = Proxy