[Haskell-beginners] scotty - autorefresh / reload

Ben Kolera ben.kolera at gmail.com
Wed Mar 19 11:11:56 UTC 2014


If you explicitly want to avoid JavaScript / XHR you could use a meta
refresh attribute in your HTML page:

http://en.m.wikipedia.org/wiki/Meta_refresh

Cheers,
Ben
On 19 Mar 2014 20:55, "Miroslav Karpis" <miroslav.karpis at gmail.com> wrote:

> 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.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140319/e46b7e8b/attachment.html>


More information about the Beginners mailing list