-
-
Save sternenseemann/790430802eda4761bebcf9d13aee3b62 to your computer and use it in GitHub Desktop.
Like python’s SimpleHTTPServer.
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
#!/usr/bin/env nix-shell | |
#!nix-shell -i runhaskell -p "haskellPackages.ghcWithPackages (hps: with hps; [wai-middleware-static warp unix])" | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Network.Wai | |
import Network.Wai.Middleware.Static | |
import Network.Wai.Handler.Warp | |
import Network.HTTP.Types.Status | |
import System.Posix.Directory | |
import System.Environment | |
main = do | |
args <- getArgs | |
let policy = | |
case args of | |
[ dir ] -> addBase dir | |
_ -> mempty | |
runEnv 8000 $ staticPolicy policy $ \req resp -> resp $ responseLBS notFound404 [] "not found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment