Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
var http = require('http');

//create a server object:
http.createServer(function (req, res) {
res.write('A Monk in Cloud'); //write a response to the client
res.end(); //end the response
}).listen(80); //the server object listens on port 80
// Set the response HTTP header with HTTP status and Content type
res.writeHead(200, {'Content-Type': 'text/plain'});

// Route the request based on the URL
switch(req.url) {
case '/':
res.end('Welcome to A Monk in Cloud');
break;
case '/about':
res.end('About A Monk in Cloud');
break;
case '/contact':
res.end('Contact A Monk in Cloud');
break;
default:
res.writeHead(404);
res.end('404 Not Found');
}
}).listen(80);

console.log('Server running on port 80');