initial commit
This commit is contained in:
30
server/app/Main.hs
Normal file
30
server/app/Main.hs
Normal file
@@ -0,0 +1,30 @@
|
||||
{-# 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"]}
|
||||
Reference in New Issue
Block a user