Created
June 25, 2013 09:50
-
-
Save funrep/5857298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
-- Extremely simple web app serving a log file | |
import Web.Scotty | |
import qualified Text.Blaze.Html5 as H | |
import Text.Blaze.Renderer.Text (renderHtml) | |
import Data.Text (Text, pack) | |
import Control.Monad.Trans (liftIO) | |
main = scotty 3000 $ do | |
f <- liftIO $ getLog | |
get "/" $ do | |
html $ renderHtml $ page f | |
get "/archive" $ do | |
html f | |
page :: Text -> H.Html | |
page t = H.docTypeHtml $ do | |
H.head $ do | |
H.title "CodeTalk IRC Logs" | |
H.body $ do | |
H.h1 "CodeTalk IRC Logs" | |
H.p "Updates every 5 minute..." | |
getLog :: IO Text | |
getLog = readFile "log.txt" >>= return . pack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
webapp.hs:15:10:
Couldn't match expected type
Data.Text.Lazy.Internal.Text' with actual type
Text'In the first argument of
html', namely
f'In a stmt of a 'do' block: html f
In the second argument of
($)', namely
do { html f }'