summaryrefslogtreecommitdiff
path: root/src/Hakyll/Preview
diff options
context:
space:
mode:
authorchrisdotcode <chris@code.sc>2014-03-24 04:33:24 -0400
committerchrisdotcode <chris@code.sc>2014-03-24 04:50:17 -0400
commit5af08f807e9022ac75625daf254a648b7e09b545 (patch)
tree7f4d7a0b8cac1e3045f4ab009f3c3165f7e38fc3 /src/Hakyll/Preview
parent1a63b931a0f0e6049e9457635af8fbd0e38dfbea (diff)
downloadhakyll-5af08f807e9022ac75625daf254a648b7e09b545.tar.gz
Add flag to bind on selected host.
Diffstat (limited to 'src/Hakyll/Preview')
-rw-r--r--src/Hakyll/Preview/Server.hs7
1 files changed, 5 insertions, 2 deletions
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