mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
pgf-server HTTP mode feature: return the contents of index.html when the URL refers to a directory
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
module ServeStaticFile where
|
||||
import System.FilePath
|
||||
import System.Directory(doesDirectoryExist)
|
||||
import Network.CGI(setHeader,outputFPS,liftIO)
|
||||
import qualified Data.ByteString.Lazy.Char8 as BS
|
||||
|
||||
serveStaticFile path =
|
||||
do b <- liftIO $ doesDirectoryExist path
|
||||
let path' = if b then path </> "index.html" else path
|
||||
serveStaticFile' path'
|
||||
|
||||
serveStaticFile' path =
|
||||
do setHeader "Content-Type" (contentTypeFromExt (takeExtension path))
|
||||
outputFPS =<< liftIO (BS.readFile path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user