-
-
Save ielcoro/7a9533c499771e949f5a to your computer and use it in GitHub Desktop.
This file contains 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
var express = require('express'); | |
var fs = require('fs'); | |
var handlebars = require('handlebars'); | |
var source = new Buffer(10); | |
// El objeto source no contiene nada | |
console.log(source.toString('utf-8')); | |
fs.readFile('home.html', function(error, content){ | |
if(error) { | |
console.log(error); | |
} else { | |
//Asignar a source los contenidos leidos | |
source = content; | |
} | |
}); | |
var app = express(); | |
app.get('/', function (req, res) { | |
// El objeto source ahora sí tendra el contenido | |
res.send(source.toString('utf-8')); | |
}); | |
var server = app.listen(3000, function () { | |
var host = server.address().address; | |
var port = server.address().port; | |
console.log('Backend listo para combatir en http://%s:%s', host, port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment