Skip to content

Instantly share code, notes, and snippets.

@aderonkeakinyemi
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aderonkeakinyemi/2bb9c59aac14df96fb70 to your computer and use it in GitHub Desktop.
Save aderonkeakinyemi/2bb9c59aac14df96fb70 to your computer and use it in GitHub Desktop.
My Server Assignment
//importing the HTTP module
var http = require('http');
//Defining the port that i want to listen to
const PORT=8080;
//a function that handles requests and sends response
function handleRequest(request, response){
response.end('Hello World');
}
//Creating a server
var server = http.createServer(handleRequest);
//starting the server
server.listen(PORT, function(){
//Callback triggered when server is successfully listening. Hurray!
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