blob: 6619d09998264c0608994bf0f6ffc60550e99224 (
plain)
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
|
module Web.Views where
import System.IO
import qualified Data.Text as T
import Data.Text (Text)
import Web.Request
import Web.Response
indexGet (Request query url method) =
return $ HtmlResponse 200 (T.pack "<strong>index</strong>")
helloGet req =
return $ HtmlResponse 200 (T.pack "<i>hello</i>")
renderTemplate :: String -> IO Response
renderTemplate name = do
template <- readTemplate name
return $ HtmlResponse 200 template
readTemplate :: String -> IO Text
readTemplate name = do
handle <- openFile ("templates/" ++ name) ReadMode
contents <- hGetContents handle
return $ T.pack contents
|