From 4561887cf459ca9c06067180a979e996b029dcdf Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 28 Dec 2009 13:46:43 +0100 Subject: Find index.html in every directory. --- src/Network/Hakyll/SimpleServer.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Network') diff --git a/src/Network/Hakyll/SimpleServer.hs b/src/Network/Hakyll/SimpleServer.hs index 80c0ff1..1a4b1c6 100644 --- a/src/Network/Hakyll/SimpleServer.hs +++ b/src/Network/Hakyll/SimpleServer.hs @@ -8,7 +8,7 @@ import Network import Control.Monad (forever, mapM_) import Control.Monad.Reader (ReaderT, runReaderT, ask, liftIO) import System.IO (Handle, hClose, hGetLine, hPutStr) -import System.Directory (doesFileExist) +import System.Directory (doesFileExist, doesDirectoryExist) import Control.Concurrent (forkIO) import System.FilePath (takeExtension) import qualified Data.ByteString.Char8 as B @@ -92,8 +92,9 @@ createGetResponse request = do -- Construct the complete fileName of the requested resource. config <- ask let uri = B.unpack (requestURI request) - fileName = (documentRoot config) ++ if uri == "/" then "/index.html" - else B.unpack (requestURI request) + isDirectory <- liftIO $ doesDirectoryExist $ documentRoot config ++ uri + let fileName = (documentRoot config) ++ if isDirectory then uri ++ "/index.html" + else uri -- Send back the page if found. exists <- liftIO $ doesFileExist fileName -- cgit v1.2.3