我有这个简单的 Wai/Warp 应用程序
app :: Wai.Application
app req respond = respond $ case Wai.rawPathInfo req of
"/" -> Wai.responseFile status200 [("Content-Type", "text/html")] "views/index.html" Nothing
_ -> notFound
notFound :: Wai.Response
notFound = Wai.responseLBS status404 [("Content-Type", "text/plain")] "404 - Not Found"
main :: IO ()
main = do
port <- getEnv "PORT"
let setting = Warp.setPort (read port :: Int) Warp.defaultSettings
putStrLn $ "start server on the port " ++ port
Warp.runSettings setting app
如何将文件夹“images”添加到路由中,以便任何图像我都可以将 index.html 中的任何图像称为“images/something.jpg”?我知道如何添加确切的路线,但在这里我需要添加整个文件夹。