Files
FlakeTest/server/app/Main.hs
2021-08-05 12:04:54 +02:00

31 lines
815 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Main where
import Data.Semigroup ((<>))
import Network.Wai.Application.Static
import Network.Wai.Handler.Warp
import Options.Applicative
import System.FilePath
import WaiAppStatic.Types
import Data.Maybe
data Config = Config
{ location :: FilePath,
port :: Int
}
configP :: Parser Config
configP =
let location = strArgument (metavar "PATH" <> help "Directory to serve")
port = argument auto (metavar "PORT" <> value 12345)
in Config <$> location <*> port
main :: IO ()
main = do
Config {..} <- execParser $ info configP fullDesc
putStrLn $ "Location: " ++ location
putStrLn $ "Port: " ++ show port
run port . staticApp $ (defaultWebAppSettings location) {ssIndices = fromMaybe [] $ toPieces ["index.html"]}