如何使用Haskell Scotty获得每条路线?

时间:2017-10-20 08:11:02

标签: rest haskell routing scotty

我有一个简单的服务器

{-# LANGUAGE OverloadedStrings #-}

import Web.Scotty
import Data.Text
import Data.Monoid (mconcat)

server :: ScottyM ()
server = do
  get "/" $ file "./index.html"

我想在所有路线上提供index.html例如。 get "*" $ file "./index.html",但这不起作用。如何实现?

1 个答案:

答案 0 :(得分:0)

与提供的示例相同: https://github.com/scotty-web/scotty

{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Data.Monoid (mconcat)

main = scotty 3000 $
    get "/:word" $ do
        file "./index.html"