
Untitled
By: a guest on
Jun 13th, 2012 | syntax:
None | size: 0.68 KB | hits: 9 | expires: Never
http.Server doesn't have addListener in node.js? It isn't a event emitter?
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.jsn');
}).listen(80, "127.0.0.1");
http.Server.addListener('request', function(req,res){
console.log(req.headers);
});
console.log('Server running at http://127.0.0.1');
var http = require('http');
var myServer = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.jsn');
});
myServer.listen(80, "127.0.0.1");
myServer.addListener('request', function(req,res){
console.log(req.headers);
});