我有一个静态网页存储在我的 Vapor 服务器的公共(public)文件夹中。它有一个index.html 文件。但是,当我导航到 root (http://localhost:8080) 时,它显示 Not found
。
我需要做什么才能使根指向index.html?
最佳答案
在 Vapor 3 上,添加家乡路线对我来说很有效。具体来说,我在 routes.swift
中添加了路由,如下所示:
router.get { req -> Future<View> in
let dir = DirectoryConfig.detect()
let path = dir.workDir + "/Public/index.html"
return try req.view().render(path)
}
关于vapor - 让根指向 Vapor 中的静态网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66145485/