Last active
October 20, 2016 16:26
-
-
Save labra/0d413e0fdefbaf4caa094e98c272d391 to your computer and use it in GitHub Desktop.
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
const http = require('http'); | |
const fs = require('fs'); | |
var personas; | |
fs.readFile("personas.json",'utf8', (err,datos) => { | |
if (err) throw err; | |
json = JSON.parse(datos); | |
console.log("Total personas:" + json.total); | |
personas = json.personas; | |
servidor(); | |
}); | |
function servidor() { | |
var server = http.createServer() | |
server.on('request',procesa); | |
server.listen(3000); | |
} | |
var procesa = function (req, res) { | |
res.writeHead(200, {'Content-Type': 'application/json'}); | |
res.end(JSON.stringify(personas)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment