Skip to content

Instantly share code, notes, and snippets.

@mattyod
Created March 23, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyod/3c3043abf0d1b44ae696 to your computer and use it in GitHub Desktop.
Save mattyod/3c3043abf0d1b44ae696 to your computer and use it in GitHub Desktop.
'use strict';
var http = require('http'),
fs = require('fs');
var filePath = './feeds/feed.json';
http.createServer(function (req, res) {
var readStream;
fs.stat(filePath, function (err, stat) {
res.writeHead(200, {
'Content-Type': 'application/json',
'Content-Length': stat.size
});
});
readStream = fs.createReadStream(filePath);
readStream.pipe(res);
}).listen(7777);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment