简体   繁体   中英

vapor can not load html and leaf

I use vapor load a html or leaf,it gives me error message '500'.The server log show me

[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]

Here is my code:

get { req in
        return try self.view.make("welcome.leaf", ["message": "Hello world!"])
    }

How can I solve this problem?

You should put your file into {Project Dir}/Resources/Views/

In your case welcome.leaf should be in /Users/apple/Desktop/QSSwiftServer/Resources/Views/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM