on master help sign in
canonicalizePath
commit97ded724628bce03f1b0d19475a091e5b45191de authorMichael Snoyman <michael@snoyman.com> dateSun 13 Mar 2011, 08:38 (16 years ago) parent13968dd
2 files changed+8−3
warp-static.cabal+2−1 warp.hs+6−2
warp-static.cabal+2−1
@@ -1,5 +1,5 @@
11Name: warp-static
2−Version: 0.0.0
2+Version: 0.0.1
33Synopsis: Static file server based on Warp and wai-app-static
44Homepage: http://github.com/snoyberg/warp-static
55License: BSD3
@@ -17,3 +17,4 @@ Executable warp
1717 , warp >= 0.3 && < 0.4
1818 , wai-app-static >= 0.0 && < 0.1
1919 , cmdargs >= 0.6.7 && < 0.7
20+ , directory >= 1.0 && < 1.2
warp.hs+6−2
@@ -6,22 +6,26 @@ import Network.Wai.Handler.Warp (run)
66import System.Environment (getArgs)
77import System.Console.CmdArgs
88import Text.Printf (printf)
9+import System.Directory (canonicalizePath)
10+import Control.Monad (unless)
911
1012data Args = Args
1113 { docroot :: FilePath
1214 , index :: [FilePath]
1315 , port :: Int
1416 , noindex :: Bool
17+ , quiet :: Bool
1518 }
1619 deriving (Show, Data, Typeable)
1720
18−defaultArgs = Args "." ["index.html", "index.htm"] 3000 False
21+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False
1922
2023main :: IO ()
2124main = do
2225 Args {..} <- cmdArgs defaultArgs
26+ docroot' <- canonicalizePath docroot
2327 args <- getArgs
24− printf "Serving directory %s on port %d with %s index files.\n" docroot port (if noindex then "no" else show index)
28+ unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)
2529 run port $ staticApp StaticSettings
2630 { ssFolder = docroot
2731 , ssIndices = if noindex then [] else index