Node Ch1 Learnings
Basic Hello World App
// Require HTTP Module from native Node Platform
var http = require('http');
// Create HTTP server with simple callback
// 200 means the request has succeeded.
// Specify the Mime type so the browser understands what it is dealing with
// Write the response data
// End the response
http.createServer(function(request,response){
response.writeHead(200, {'Content-Type':'text/plain'});
response.write('Hello World\n');
response.end();
});
// Tell the server to start with the port 3000
server.listen(3000);
// Log out to the terminal for the user to go to the correct address
console.log('Server running at http://localhost:300');
Written by Jeff Scott Ward
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Node
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#