swift - vapor 无法加载 html 和 leaf

标签 swift vapor

我使用 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/

相关文章:

swift - Vapor 一次上传多个文件

swift - 尝试在 Bluemix 上运行 Swift Vapor - 找不到 404 : Requested route does not exist

ios - X代码 6 : I can't select a view by its storyboard ID

swift - 添加带有约束的 subview 不起作用

swift - 使用 Swift Vapor 3.0 上传文件

swift - 评估唯一性时忽略软删除条目的数据库约束

swift - 如果图像仅使用基础框架,我可以验证数据吗

c# - AvPlayer 正在下载 mp3 而不是流式传输

xcode - 关于 Swift 3.0 和 for 循环的小语法问题

ios - 标签未出现在 UICollectionView 单元格上方