2

我正在使用 wai-app-static 静态包来服务一个小型网站。最初我将其称为:

staticApp defaultFileServerSettings root 

世界上一切都很好。不过,我想改用 defaultWebAppSettings(因为这是一个网站)。我能够让它工作,所以如果我去http://localhost:3000/index.html,那很好,但我还需要设置从根文件夹到索引站点(即http://localhost:3000 --> http://localhost:3000/index.html)的重定向。

根据我在代码中看到的内容,我尝试了以下几种变体:

(defaultWebAppSettings root) { ssIndices = map unsafeToPiece ["index.html"],
                               ssRedirectToIndex = True }

我能够编译和运行服务器,但我无法让重定向工作。

任何指示或想法将不胜感激!

谢谢

4

2 回答 2

1

嗯,我不知道 ssIndices 或 ssRedirectToIndex 设置。我为具有动态和静态部分的应用程序所做的是对 / 的请求,将请求更改为 /index.html 并将其发送到“静态服务器”。 https://github.com/LeifW/online-typechecker/blob/master/index.hs#L20

于 2013-12-09T05:06:07.300 回答
1

这段代码对我有用

httpApp :: Wai.Application
httpApp = Static.staticApp $ s {Static.ssIndices = [Static.unsafeToPiece "index.html"]} where s = Static.defaultWebAppSettings "./static"
于 2018-11-16T22:24:31.097 回答