Created
June 25, 2018 08:24
-
-
Save islandjoe/94889ad649e5404b541cd2935b08ddf8 to your computer and use it in GitHub Desktop.
Meme Machine: routes.swift - root route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get { (req)-> Future<View> in | |
let fileMgr = FileManager() | |
guard let files = try? fileMgr.contentsOfDirectory(at: origDir, includingPropertiesForKeys: nil) else { | |
throw Abort(.internalServerError) | |
} | |
let allFiles = files.map { $0.lastPathComponent } | |
let visibleFiles = allFiles.filter { !$0.hasPrefix(".") } | |
let context = ["files": visibleFiles] | |
return try req.view().render("home", context) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment