{-# LANGUAGE OverloadedStrings #-} module Main where import Network.Wai.Handler.Warp import Network.Wai import Network.HTTP.Types import Data.Text.Lazy (fromStrict) import Data.Text.Lazy.Encoding (encodeUtf8) import Hearth (renderPage) main :: IO () main = do runEnv 2019 servePage servePage :: Application servePage req respond = case requestMethod req of "GET" | Just resp <- renderPage (rawPathInfo req) (queryString req) -> respond $ responseLBS status200 [] $ encodeUtf8 $ fromStrict resp _ -> respond $ responseLBS status404 [] "Page not found!"