Skip to content

Instantly share code, notes, and snippets.

@ambirex
Forked from ruturajv/beacon.js
Created July 30, 2014 22:30
Show Gist options
  • Save ambirex/e588cf98fa892c756061 to your computer and use it in GitHub Desktop.
Save ambirex/e588cf98fa892c756061 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