~alcinnz/bureaucromancy

ref: 02191300f27a5d30c34b2433a283a15b7537d52e bureaucromancy/app/Main.hs -rw-r--r-- 562 bytes
02191300 — Adrian Cochrane Fix issues README link 1 year, 4 months ago
                                                                                
fa8b4fac Adrian Cochrane
9ecdfe8a Adrian Cochrane
fa8b4fac Adrian Cochrane
9ecdfe8a Adrian Cochrane
fa8b4fac Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# 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!"