Added the Static and StaticFile reps. Special responses set headers properly (redirect works).
28 lines
532 B
Plaintext
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}
|