on master help sign in
Initial code import
commit8ed6efc2dd834e420e040f74c6f29cbe270c946f authorMichael Snoyman <michael@snoyman.com> dateThu 27 Jan 2011, 17:54 (16 years ago) parent5bf40d9
2 files changed+39
warp-static.cabal+18 warp.hs+21
warp-static.cabalnew file+18
@@ -0,0 +1,18 @@
1+Name: warp-static
2+Version: 0.0.0
3+Synopsis: Static file server based on Warp and wai-app-static
4+Homepage: http://github.com/snoyberg/warp-static
5+License: BSD3
6+License-file: LICENSE
7+Author: Michael Snoyman
8+Maintainer: michael@snoyman.com
9+Category: Web
10+Build-type: Simple
11+Cabal-version: >=1.2
12+
13+
14+Executable warp
15+ Main-is: warp.hs
16+ Build-depends: base >= 4 && < 5
17+ , warp >= 0.3 && < 0.4
18+ , wai-app-static >= 0.0 && < 0.1
warp.hsnew file+21
@@ -0,0 +1,21 @@
1+import Network.Wai.Application.Static
2+ ( StaticSettings (..), staticApp, defaultMimeTypeByExt, defaultListing
3+ )
4+import Network.Wai.Handler.Warp (run)
5+import System.Environment (getArgs)
6+
7+main :: IO ()
8+main = do
9+ args <- getArgs
10+ (folder, port) <- return $
11+ case args of
12+ [] -> (".", 3000)
13+ [f] -> (f, 3000)
14+ [f, p] -> (f, read p)
15+ _ -> error "Usage: warp-static [root [port]]"
16+ run port $ staticApp StaticSettings
17+ { ssFolder = folder
18+ , ssIndices = ["index.html", "index.htm"]
19+ , ssListing = Just defaultListing
20+ , ssGetMimeType = return . defaultMimeTypeByExt
21+ }