import HAppS


handler :: Monad m => () -> Request -> m (Either Request (IO Result))
handler () rq = respond $ do
   dictList <- readFile "/usr/share/dict/words" >>= return . words
   let msg = case (word `elem` dictList) of
         True  -> "found"
         False -> "NOT found"
   toMessageM $ concat [ "\"", word, "\" ", msg, " in the dictionary" ]
   where word = lookS 50 rq "word"


main :: IO ()
main = stdHTTP
   [ noState 
   , debugFilter
   , h ["lookup"] POST $ handler
   ]

