Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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