Skip to content

Instantly share code, notes, and snippets.

@timstott
Created September 19, 2015 17:37
Show Gist options
  • Save timstott/52417efa3b0069e76ef2 to your computer and use it in GitHub Desktop.
Save timstott/52417efa3b0069e76ef2 to your computer and use it in GitHub Desktop.
Basic node.js server
#!/usr/bin/env node
var http = require('http');
// Port to listen on
const PORT=8085;
// Function handling request and response
function handleRequest(request, response){
console.log(request);
response.end('OK');
}
// Create a server
var server = http.createServer(handleRequest);
// Start server
server.listen(PORT, function(){
console.log("Server listening on: http://localhost:%s", PORT);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment