-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.hs
More file actions
62 lines (47 loc) · 1.35 KB
/
Application.hs
File metadata and controls
62 lines (47 loc) · 1.35 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveGeneric #-}
module Application (main, App) where
import System.Process
import Yesod
import Network.HTTP.Types (status201, status204)
--routes:
import Handlers.Info.InfoContent
import Handlers.Map.MapHandler
import Handlers.Player.PlayerHandler
--persistence
import qualified Persistence.Red as Red
import qualified Tool.StrTools as Str
--json
import Data.Aeson
import GHC.Generics
--Model
import Model.PlayerInfo
--tools
import Data.Text
data App = App { getSiteInfo :: SiteInfo, getGameMap :: GameMap, getGamePlayer :: GamePlayer }
mkYesod "App" [parseRoutes|
/ HomeR GET
/host HostR GET
/info SiteInfoR SiteInfo getSiteInfo
/map GameMapR GameMap getGameMap
/player GamePlayerR GamePlayer getGamePlayer
|]
instance Yesod App
getHomeR :: Handler Html
getHomeR = defaultLayout
[whamlet|
Hello - - - | ** | ** | - - -
|]
getHostR :: Handler Value
getHostR = do
hostname' <- liftIO hostname
return $ object ["msg" .= hostname']
hostname :: IO String
hostname = readProcess "hostname" [] ""
main :: IO ()
main = warp 3000 $ App SiteInfo GameMap GamePlayer