Created
August 30, 2012 08:10
-
-
Save dpwiz/3524014 to your computer and use it in GitHub Desktop.
This file contains 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
Building scotty-streaming-0.1.0.0... | |
Preprocessing executable 'scotty-streaming' for scotty-streaming-0.1.0.0... | |
[1 of 1] Compiling Main ( Main.hs, dist/build/scotty-streaming/scotty-streaming-tmp/Main.o ) | |
Linking dist/build/scotty-streaming/scotty-streaming ... | |
Setting phasers to stun... (port 3000) (ctrl-c to quit) | |
in the handler. | |
source started. | |
send: resource vanished (Connection reset by peer) | |
in the handler. | |
source started. | |
send: resource vanished (Connection reset by peer) |
This file contains 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 #-} | |
module Main where | |
import Web.Scotty | |
import Control.Monad | |
import Control.Monad.Trans | |
import qualified Control.Monad.Trans.Resource as RT | |
import Control.Concurrent (threadDelay) | |
import Data.Conduit | |
import Blaze.ByteString.Builder (Builder) | |
import qualified Blaze.ByteString.Builder.ByteString as BBBB | |
import Data.String | |
import qualified Data.ByteString.Char8 as BS | |
main = scotty 3000 $ get "/test" $ do | |
liftIO $ putStrLn "in the handler." | |
source $ do | |
lift . RT.register $ putStrLn "cleanup!" | |
liftIO $ putStrLn "source started." | |
yield Flush | |
forever $ do | |
yield $ bchunk "whatever" | |
yield Flush | |
liftIO $ threadDelay 10000 | |
bchunk = Chunk . BBBB.fromByteString . BS.pack |
This file contains 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
-- Initial scotty-streaming.cabal generated by cabal init. For further | |
-- documentation, see http://haskell.org/cabal/users-guide/ | |
name: scotty-streaming | |
version: 0.1.0.0 | |
-- synopsis: | |
-- description: | |
-- license: | |
license-file: LICENSE | |
-- author: | |
-- maintainer: | |
-- copyright: | |
-- category: | |
build-type: Simple | |
cabal-version: >=1.8 | |
executable scotty-streaming | |
main-is: Main.hs | |
-- other-modules: | |
build-depends: base ==4.5.*, scotty, conduit, blaze-builder, mtl, bytestring, resourcet | |
ghc-options: -O2 |
This file contains 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
import Distribution.Simple | |
main = defaultMain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment