diff options
| author | Andrew Guschin <saintruler@gmail.com> | 2020-11-26 13:55:55 +0400 |
|---|---|---|
| committer | Andrew Guschin <saintruler@gmail.com> | 2020-11-26 13:55:55 +0400 |
| commit | 446602fe336ad1c2a23e3d50d7cd1d1356fcc9de (patch) | |
| tree | 74b8a1ca93c17d22f7876f6aba80ee10c3851d3b /Main.hs | |
Initial commit
Diffstat (limited to 'Main.hs')
| -rw-r--r-- | Main.hs | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -0,0 +1,25 @@ +module Main where + +import System.IO +import Response +import Router + +renderTemplate name = do + template <- readTemplate name + return $ HtmlResponse 200 template + +readTemplate name = do + handle <- openFile ("templates/" ++ name) ReadMode + hGetContents handle + +route url method + | url == "/" = renderTemplate "index.html" + | url == "/hello" = renderTemplate "hello.html" + +table = [ + Route +] + +main = do + response <- route "/hello" "GET" + print $ getContent response
\ No newline at end of file |