[Haskell-beginners] scotty - autorefresh / reload

Miroslav Karpis miroslav.karpis at gmail.com
Wed Mar 19 10:55:22 UTC 2014


Hi, please is there a way how I could autorefresh / reload the page in
scotty?


A small example, where I would like to see that the time refreshes every
second:

{-# LANGUAGE OverloadedStrings #-}

import Web.Scotty
import Control.Monad.Trans (liftIO)
import qualified Data.Text.Lazy as L (Text, pack)

import Data.Time.Clock

main = scotty 3005 $ do
get "/" $ do
time <- liftIO getTime
html time


getTime :: IO L.Text
getTime = do
utcTime <- getCurrentTime
let timeText = L.pack $ show utcTime
return timeText


Cheers,
M.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140319/5d3c680f/attachment.html>


More information about the Beginners mailing list