{-# LANGUAGE OverloadedStrings #-} module Main where import Data.List import Data.ByteString.Lazy (fromStrict) import Text.Printf import Network.Wai import Network.HTTP.Types import Network.Wai.Handler.Warp (run) headers :: ResponseHeaders headers = [("Content-Type", "text/html;charset=UTF-8")] app :: Application app request respond = respond $ case rawPathInfo request of "/" -> index _ -> errorResponse index :: Response index = responseFile status200 headers "pages/index.html" Nothing responseLBS status200 [("Content-Type", "text/plain")] "Hello, world!" errorResponse :: Response errorResponse = responseFile status200 headers "pages/error.html" Nothing main :: IO () main = do putStrLn $ "http://localhost:8080/" run 8080 app