Created
November 21, 2016 01:33
-
-
Save singleseeker/e038bdaadce7f7f82896510ffd85f47e to your computer and use it in GitHub Desktop.
browsersync api post .
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
middleware: [ | |
{ | |
route: "/api", | |
handle: function (req, res, next) { | |
var url = req.url; | |
var filename = __dirname + '/api' + url; | |
if (url.indexOf('.json') > -1 && fs.existsSync(filename)) { | |
var contents = fs.readFileSync(filename, { | |
encoding: 'utf8' | |
}); | |
res.end(contents); | |
} else { | |
next(); | |
} | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment