warp-static 0.0.0 → 0.0.1
raw patch · 2 files changed
+9/−2 lines, 2 filesdep +directory
Dependencies added: directory
Files
- warp-static.cabal +2/−1
- warp.hs +7/−1
warp-static.cabal view
@@ -1,5 +1,5 @@ Name: warp-static-Version: 0.0.0+Version: 0.0.1 Synopsis: Static file server based on Warp and wai-app-static Homepage: http://github.com/snoyberg/warp-static License: BSD3@@ -17,3 +17,4 @@ , warp >= 0.3 && < 0.4 , wai-app-static >= 0.0 && < 0.1 , cmdargs >= 0.6.7 && < 0.7+ , directory >= 1.0 && < 1.2
warp.hs view
@@ -5,21 +5,27 @@ import Network.Wai.Handler.Warp (run) import System.Environment (getArgs) import System.Console.CmdArgs+import Text.Printf (printf)+import System.Directory (canonicalizePath)+import Control.Monad (unless) data Args = Args { docroot :: FilePath , index :: [FilePath] , port :: Int , noindex :: Bool+ , quiet :: Bool } deriving (Show, Data, Typeable) -defaultArgs = Args "." ["index.html", "index.htm"] 3000 False+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False main :: IO () main = do Args {..} <- cmdArgs defaultArgs+ docroot' <- canonicalizePath docroot args <- getArgs+ unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index) run port $ staticApp StaticSettings { ssFolder = docroot , ssIndices = if noindex then [] else index