{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Rib.Server
( serve,
)
where
import Network.Wai.Application.Static (defaultFileServerSettings, staticApp)
import qualified Network.Wai.Handler.Warp as Warp
import Relude
serve ::
Int ->
FilePath ->
IO ()
serve port path = do
putStrLn $ "[Rib] Serving " <> path <> " at http://" <> host <> ":" <> show port
Warp.runSettings settings app
where
app = staticApp $ defaultFileServerSettings path
host = "127.0.0.1"
settings =
Warp.setHost (fromString host)
$ Warp.setPort port
$ Warp.defaultSettings