diff options
Diffstat (limited to 'Web/Views.hs')
| -rw-r--r-- | Web/Views.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Web/Views.hs b/Web/Views.hs index b6ae013..6619d09 100644 --- a/Web/Views.hs +++ b/Web/Views.hs @@ -1,20 +1,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 "<strong>index</strong>" + return $ HtmlResponse 200 (T.pack "<strong>index</strong>") helloGet req = - return $ HtmlResponse 200 "<i>hello</i>" + 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 - hGetContents handle
\ No newline at end of file + contents <- hGetContents handle + return $ T.pack contents |