Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Forked from ruturajv/beacon.js
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save fizerkhan/f195f323f80b04ade5c3 to your computer and use it in GitHub Desktop.

Select an option

Save fizerkhan/f195f323f80b04ade5c3 to your computer and use it in GitHub Desktop.
http = require('http');
url = require('url');
http.createServer(function(req, res){
var requestURL = url.parse(req.url, true)['pathname'];
if (requestURL == '/log.gif') {
var imgHex = '47494638396101000100800000dbdfef00000021f90401000000002c00000000010001000002024401003b';
var imgBinary = new Buffer(imgHex, 'hex');
res.writeHead(200, {'Content-Type': 'image/gif' });
res.end(imgBinary, 'binary');
// Do MySQL/Redis/MongoDB logging
} else {
res.writeHead(200, {'Content-Type': 'text/plain' });
res.end('');
}
}).listen(8080); // Ofcourse u can use whatever IP/port combination you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment