summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2020-11-26 13:55:55 +0400
committerAndrew Guschin <saintruler@gmail.com>2020-11-26 13:55:55 +0400
commit446602fe336ad1c2a23e3d50d7cd1d1356fcc9de (patch)
tree74b8a1ca93c17d22f7876f6aba80ee10c3851d3b /Main.hs
Initial commit
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs25
1 files changed, 25 insertions, 0 deletions
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