summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src/Minilang/App.hs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2025-11-04 09:06:01 +0100
committerArnaud Bailly <arnaud@pankzsoft.com>2025-11-04 09:06:01 +0100
commitdf879037d135c0b300735185d5fdc0857ed797d6 (patch)
tree60ea569254a110be6fc53453e99312e2f16fc384 /lambda-calcul/haskell/src/Minilang/App.hs
parent1083bb7758a2dfe3f2861bf802627cec16933861 (diff)
downloadlambda-nantes-df879037d135c0b300735185d5fdc0857ed797d6.tar.gz
Serve index.html when requesting '/'
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/App.hs')
-rw-r--r--lambda-calcul/haskell/src/Minilang/App.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/App.hs b/lambda-calcul/haskell/src/Minilang/App.hs
index 2d21961..8c1fb2b 100644
--- a/lambda-calcul/haskell/src/Minilang/App.hs
+++ b/lambda-calcul/haskell/src/Minilang/App.hs
@@ -1,14 +1,20 @@
module Minilang.App where
-import Minilang.API (LambdaAPI, Score (..))
-import Servant.Server (Handler, Server)
-import Data.Time (getCurrentTime)
import Control.Monad.IO.Class (liftIO)
+import Data.Time (getCurrentTime)
+import Minilang.API (LambdaAPI, Score (..))
+import Network.Wai.Application.Static (defaultFileServerSettings, staticApp)
+import Servant ((:<|>) (..))
+import Servant.Server (Application, Handler, Server, Tagged (..))
lambdaApp :: Server LambdaAPI
-lambdaApp = getLeaderboard
+lambdaApp = getLeaderboard :<|> Tagged staticResources
getLeaderboard :: Handler [Score]
getLeaderboard = do
now <- liftIO getCurrentTime
pure [Score "Alice" 95 now, Score "Bob" 88 now]
+
+-- | Serve static resources under `public/` directory
+staticResources :: Application
+staticResources = staticApp (defaultFileServerSettings "public")