Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (32 sloc) 1.117 kb
7c26b11e »
2009-06-29 Upgrade to blaaargh!
1 {-# LANGUAGE ScopedTypeVariables #-}
2
c43c6fbc »
2009-03-23 First checkin
3 module Main where
4
5 import Happstack.Server hiding (port)
7c26b11e »
2009-06-29 Upgrade to blaaargh!
6 --import Happstack.Server.FastCGI
c43c6fbc »
2009-03-23 First checkin
7
8 import Homepage
9
7c26b11e »
2009-06-29 Upgrade to blaaargh!
10 import Control.Exception
11 import Prelude hiding (catch)
c43c6fbc »
2009-03-23 First checkin
12 import System.Environment
13
7c26b11e »
2009-06-29 Upgrade to blaaargh!
14 -- import System.Log.Handler.Simple
15 -- import System.Log.Logger
16
17
18
c43c6fbc »
2009-03-23 First checkin
19 main :: IO ()
20 main = do
21 args <- getArgs
22 case args of
23 [port] -> startServer $ read port
24 _ -> putStrLn "pass me a port number, please"
25
26
27
28 startServer :: Int -> IO ()
29 startServer port = do
30 -- this IO action initializes the homepage's state and returns a
31 -- monad evaluator function
32 --
33 -- eval :: HomepageMonad a -> IO a
34 --
35 -- we'll pass this into simpleHTTP'. (the HTTP server expects to
36 -- be given IO and needs a function to produce an IO action given
37 -- our custom state monad.)
7c26b11e »
2009-06-29 Upgrade to blaaargh!
38 getBlaaarghDir >>= initHomepage >>= go
c43c6fbc »
2009-03-23 First checkin
39
40 where
41 go eval = simpleHTTP' eval (Conf port Nothing) topLevelHandler
7c26b11e »
2009-06-29 Upgrade to blaaargh!
42
43
44 getBlaaarghDir :: IO FilePath
45 getBlaaarghDir = getEnv "BLAAARGH_DIR" `catch`
46 \(_ :: SomeException) -> return "data"
47
48
49
Something went wrong with that request. Please try again.