From 5af08f807e9022ac75625daf254a648b7e09b545 Mon Sep 17 00:00:00 2001 From: chrisdotcode Date: Mon, 24 Mar 2014 04:33:24 -0400 Subject: Add flag to bind on selected host. --- src/Hakyll/Preview/Server.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Hakyll/Preview') diff --git a/src/Hakyll/Preview/Server.hs b/src/Hakyll/Preview/Server.hs index 14cf377..ef1c3c5 100644 --- a/src/Hakyll/Preview/Server.hs +++ b/src/Hakyll/Preview/Server.hs @@ -8,6 +8,7 @@ module Hakyll.Preview.Server -------------------------------------------------------------------------------- import Control.Monad.Trans (liftIO) +import qualified Data.ByteString.Char8 as B import qualified Snap.Core as Snap import qualified Snap.Http.Server as Snap import qualified Snap.Util.FileServe as Snap @@ -31,13 +32,15 @@ static directory preServe = -- | Main method, runs a static server in the given directory staticServer :: FilePath -- ^ Directory to serve -> (FilePath -> IO ()) -- ^ Pre-serve hook + -> String -- ^ Host to bind on -> Int -- ^ Port to listen on -> IO () -- ^ Blocks forever -staticServer directory preServe port = +staticServer directory preServe host port = Snap.httpServe config $ static directory preServe where -- Snap server config - config = Snap.setPort port + config = Snap.setBind (B.pack host) + $ Snap.setPort port $ Snap.setAccessLog Snap.ConfigNoLog $ Snap.setErrorLog Snap.ConfigNoLog $ Snap.emptyConfig -- cgit v1.2.3