From 446602fe336ad1c2a23e3d50d7cd1d1356fcc9de Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Thu, 26 Nov 2020 13:55:55 +0400 Subject: Initial commit --- Main.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Main.hs (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs new file mode 100644 index 0000000..1bc06d5 --- /dev/null +++ b/Main.hs @@ -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 -- cgit v1.2.3