yesod/examples/fact.lhs
Michael Snoyman 7ab3b406db Added fact example and fixed a few bugs.
Added the Static and StaticFile reps.
Special responses set headers properly (redirect works).
2009-12-21 16:05:48 +02:00

28 lines
532 B
Plaintext

\begin{code}
{-# LANGUAGE QuasiQuotes #-}
import Yesod
import Hack.Handler.SimpleServer
data Fact = Fact
instance Yesod Fact where
handlers = [$resources|
/:
Get: index
/#num:
Get: fact
/fact:
Get: factRedirect
|]
index = return $ StaticFile TypeHtml "examples/fact.html"
fact i = return $ toHtmlObject $ show $ product [1..fromIntegral i]
factRedirect = do
i <- getParam "num"
redirect $ "../" ++ i ++ "/"
return ()
main :: IO ()
main = putStrLn "Running..." >> run 3000 (toHackApp Fact)
\end{code}