Created
May 21, 2012 02:09
-
-
Save mdmarek/2760277 to your computer and use it in GitHub Desktop.
Wai+Warp file server with routes. Used GHC 7.4, Wai 1.1, Warp 1.1 versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
-- | Wai+Warp file server with routes. Used GHC 7.4, Wai 1.1, Warp 1.1 versions. | |
module Main where | |
import Network.HTTP.Types (status200) | |
import Network.Wai (Application,responseLBS) | |
import Network.Wai.Middleware.Router (router,dir) | |
import Network.Wai.Handler.Warp (run) | |
import Network.Wai.Application.Static | |
( StaticSettings(..) | |
, staticApp | |
, fileSystemLookup | |
, defaultWebAppSettings ) | |
-- | Static files application, and the default. | |
appDefault :: Application | |
appDefault = staticApp defaultWebAppSettings | |
{ ssFolder = fileSystemLookup "/home/ubuntu/tomugen.com" | |
, ssIndices = ["index.html"] | |
} | |
-- | Json api application. | |
appApi :: Application | |
appApi _ = return $ responseLBS status200 | |
[("Content-Type", "application/json")] "{}" | |
-- | Routing all API calls to appApi. | |
app :: Application | |
app = router [ dir "/api" appApi ] appDefault | |
-- | Start Warp server on port 8080. | |
main :: IO () | |
main = do | |
putStrLn $ "http://*:8080/" | |
run 8080 $ app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unfortunately i get this error every time and yes, it don't seem to support that, maybe version fault.