Skip to content

Instantly share code, notes, and snippets.

@casey-chow
Last active December 15, 2015 12:09
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 casey-chow/5257970 to your computer and use it in GitHub Desktop.
Save casey-chow/5257970 to your computer and use it in GitHub Desktop.
var fs = require('fs');
http.createServer(function (req, res) {
fs.readFile('/path/to/json', function (err, data) {
var html = '<table>';
for (var elem in data) {
if (data.hasOwnProperty(elem)) {
html += '<tr><td>' + elem + '</td><td>' + data[elem] + '</td></tr>';
}
}
html += '</table>';
res.writeHead(200, {"Content-Type": "text/html"});
res.end(html);
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment