Skip to content

Instantly share code, notes, and snippets.

@snoyberg
Created July 11, 2013 05:03
Show Gist options
  • Save snoyberg/5972643 to your computer and use it in GitHub Desktop.
Save snoyberg/5972643 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
module FileViewer where
import Control.Concurrent (forkIO)
import Control.Monad (void)
import Network.Wai.Application.Static (defaultFileServerSettings,
staticApp)
import Network.Wai.Handler.Warp (run)
import Prelude (IO, read, ($))
import System.Environment (getEnv)
fileViewer :: IO a -> IO ()
fileViewer action = do
void $ forkIO $ void action
portS <- getEnv "PORT"
let port = read portS
run port $ staticApp $ defaultFileServerSettings "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment