{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Wai.Handler.Warp
import Network.Wai
import Network.HTTP.Types
import Text.HTML.Form.WebApp
import Data.Text.Lazy.Encoding (encodeUtf8)
import Data.Text.Lazy (fromStrict)
main :: IO ()
main = do
runEnv 2018 servePage
servePage req respond = do
ret <- renderPage Form (pathInfo req) (queryString req)
case ret of
Just txt -> respond $ responseLBS status200 [] $ encodeUtf8 $ fromStrict txt
Nothing -> respond $ responseLBS status404 [] "Unknown input or operation!"