我使用 vapor 加载 html 或 leaf,它给我错误消息“500”。服务器日志显示给我
[Data File Error: unable to load file at path /Users/apple/Desktop/QSSwiftServer/Resources/Views/welcome.leaf]
[Identifier: Core.DataFileError.load]
[Possible Causes: file doesn't exist, missing read permissions at specified path, data read is corrupted, system issue]
[Suggested Fixes: ensure that file permissions are correct for specified paths]
[Documentation Links: https://developer.apple.com/reference/foundation/filemanager]
这是我的代码:
get { req in
return try self.view.make("welcome.leaf", ["message": "Hello world!"])
}
我该如何解决这个问题?
最佳答案
你应该把你的文件放到{Project Dir}/Resources/Views/
在你的情况下 welcome.leaf
应该在 /Users/apple/Desktop/QSSwiftServer/Resources/Views/
关于swift - vapor 无法加载 html 和 leaf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46312635/