Skip to content

Instantly share code, notes, and snippets.

@Siedrix
Created October 9, 2013 15:45
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 Siedrix/6903346 to your computer and use it in GitHub Desktop.
Save Siedrix/6903346 to your computer and use it in GitHub Desktop.
Simple web server
var express = require('express.io');
var server = express();
var mensajes = [];
var respuestas = []; // <---------
server.get('/', function (req, res) {
res.send('Hello World');
});
server.get('/mensajes', function (req, res) {
// res.send(mensajes+ '<script>setTimeout(function(){window.location.reload()}, 1000)</script>');
respuestas.push(res);
});
server.get('/mensajes/:message', function (req, res) {
mensajes.push(req.params.message);
// Mandar todos los request
respuestas.forEach(function(res){
res.send(mensajes+ '<script>window.location.reload()</script>');
});
res.send('Gracias por mandar: ' + req.params.message);
});
server.listen(3000);
console.log('Server corriendo en localhost:3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment