-- with gracious thanks to mightybyte: -- http://softwaresimply.blogspot.com/2008_02_01_archive.html module Main where import HAppS.Server import Controller import Misc import System.Environment import StateStuff main = do -- let p = 5001 let usageMessage = "usage example: happs-tutorial 5001 (starts the app on port 5001)" args <- getArgs case args of [port] -> runserver (read port) otherwise -> do putStrLn usageMessage -- run the happs server on some port runserver p = withProgName "happs-tutorial" $ do startSystemState entryPoint -- start the HAppS state system putStrLn $ "happs tutorial starting on port " ++ (show p) ++ "\n" ++ "shut down with ctrl-c" simpleHTTP (Conf {port=p}) controller -- start serving web pages where entryPoint :: Proxy AppState entryPoint = Proxy runInGhci = do putStrLn $ "happs tutorial running ins ghci. \n" ++ "exit :q ghci completely and reenter ghci, before restarting." runserver 5001