allow for 404 files and be graceful if one doesnt exist

This commit is contained in:
John McLear 2013-02-04 22:00:31 +00:00
parent a5fb1e33de
commit 2affccf900

View file

@ -80,5 +80,16 @@ exports.restartServer = function () {
});
hooks.callAll("expressCreateServer", {"app": app, "server": server});
//The 404 Route (ALWAYS Keep this as the last route)
app.get('*', function(req, res){
var rootPath = path.resolve(npm.dir, '..');
var customFile = rootPath + '/src/static/custom/404.html';
if(fs.existsSync(customFile)){ // if a custom 404 page exists..
res.sendfile(customFile);
} else {
res.send('Resource does not exist', 404);
}
});
server.listen(settings.port, settings.ip);
}