diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-27 20:33:18 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-27 20:33:18 +0100 |
commit | d47227ddbb3cc312691a62b8733d31105b21c8d9 (patch) | |
tree | d27e91bc4276876c45732894ef49f6154f95ca19 /src | |
parent | 849b49aa53fcc50064854a44d34eb1cd04e502d3 (diff) | |
download | hakyll-d47227ddbb3cc312691a62b8733d31105b21c8d9.tar.gz |
Made document root configurable.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Hakyll/SimpleServer.hs | 9 | ||||
-rw-r--r-- | src/Text/Hakyll.hs | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Network/Hakyll/SimpleServer.hs b/src/Network/Hakyll/SimpleServer.hs index 63006f2..80c0ff1 100644 --- a/src/Network/Hakyll/SimpleServer.hs +++ b/src/Network/Hakyll/SimpleServer.hs @@ -159,14 +159,15 @@ respond handle = do putHeader (key, value) = B.hPutStr handle $ key `B.append` B.pack ": " `B.append` value `B.append` B.pack "\r\n" --- | Start a simple http server on the given 'PortNumber'. -simpleServer :: PortNumber -> IO () -simpleServer port = do +-- | Start a simple http server on the given 'PortNumber', serving the given +-- directory. +simpleServer :: PortNumber -> FilePath -> IO () +simpleServer port root = do putStrLn $ "Starting hakyll server on port " ++ show port ++ "..." socket <- listenOn (PortNumber port) forever (listen socket) where -- A default configuration. - config = ServerConfig { documentRoot = "_site" + config = ServerConfig { documentRoot = root , portNumber = port } diff --git a/src/Text/Hakyll.hs b/src/Text/Hakyll.hs index 9d2f86c..bafe4a8 100644 --- a/src/Text/Hakyll.hs +++ b/src/Text/Hakyll.hs @@ -45,4 +45,4 @@ help = do ++ name ++ " server [port] Run a local test server.\n" server :: Integer -> IO () -server p = do simpleServer (fromIntegral $ p) +server p = do simpleServer (fromIntegral $ p) "_site" |