Skip to content

Instantly share code, notes, and snippets.

@mark-adams
Created October 29, 2012 21:55
Show Gist options
  • Save mark-adams/3976795 to your computer and use it in GitHub Desktop.
Save mark-adams/3976795 to your computer and use it in GitHub Desktop.
SimpleLTC API Echo Server
// API Echo Server
// Developed by Mark Adams <[email protected]>
var net = require('net');
var server = net.createServer(function(c){
c.on('data', function(buffer){
c.write('HTTP/1.1 200 OK\n\r\n');
c.write(buffer.toString());
c.end();
console.log('%s - Request received from %s', new Date(), c.remoteAddress);
console.log('Raw request contents:');
process.stdout.write(buffer.toString())
});
});
server.listen(80, function() {
console.log('Server bind successful! Awaiting connections...');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment