Skip to content

Instantly share code, notes, and snippets.

@banacorn
Created August 5, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banacorn/6157306 to your computer and use it in GitHub Desktop.
Save banacorn/6157306 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (status200)
cedartrunk request = do
case referer of
Nothing -> return $ ResponseFile status200 [("Content-Type", "text/html")] "index.html" Nothing
Just _ -> return $ ResponseFile status200 [] path Nothing
where path = tail . tail . init . show . rawPathInfo $ request
referer = lookup "Referer" (requestHeaders request)
main = run 3000 $ cedartrunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment