Skip to content

Instantly share code, notes, and snippets.

@funrep
Created June 25, 2013 09:50
Show Gist options
  • Save funrep/5857298 to your computer and use it in GitHub Desktop.
Save funrep/5857298 to your computer and use it in GitHub Desktop.
{-# 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
@funrep
Copy link
Author

funrep commented Jun 25, 2013

webapp.hs:15:10:
Couldn't match expected type Data.Text.Lazy.Internal.Text' with actual typeText'
In the first argument of html', namelyf'
In a stmt of a 'do' block: html f
In the second argument of ($)', namelydo { html f }'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment