-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
31 lines (27 loc) · 1.21 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, TemplateHaskell #-}
module Main (main) where
import Control.Monad (msum)
import Happstack.Server (port, toResponse ,simpleHTTP, nullConf, dir, notFound, seeOther, serveDirectory, Browsing(..))
import Web.Routes.Happstack (implSite)
import Data.Acid
import Control.Concurrent (killThread, forkIO)
import Auth
import Types
import RouteHandlers
main :: IO ()
main = do
users <- openLocalState (UserMap emptyMap)
sessions <- openLocalState (SessionMap emptyMap)
sdb <- openLocalState (sdbEmpty)
httpThreadId <- forkIO $ simpleHTTP nullConf{ port = 80 } $
msum [ dir "favicon.ico" $ notFound (toResponse ())
, implSite "http://core.lan" "/api/" (site sdb users sessions)
, serveDirectory DisableBrowsing ["index.html"] "./static"
, seeOther "" (toResponse ())
]
c <- getChar
killThread httpThreadId
closeAcidState sdb
closeAcidState users
closeAcidState sessions
putStrLn "Server stopped."