Please enable JavaScript.
Coggle requires JavaScript to display documents.
MEAN 2 (Node (different programming approach (tries to deal with…
Target of the article
Create Hello World
var http = require('http');
var port = process.env.PORT || 3000; http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(port);
second line
line uses the built-in process object to access the surrounding environment. In this case, it uses the “env” object within the process object to determine whether an environment variable named PORT is set to anything. If it is, I’ll use that as the port on which to run the server. Otherwise, I’ll use the default port 3000
next lines
The sole parameter is a function literal that takes a req (HTTP request) object and a res (HTTP response) object as parameters, and uses res to write the HTTP response back. This idiom is ubiquitous throughout all levels of the Node.js stack.
-
-
-
Wrapping Up
Node.js isn’t just an HTTP pipeline.Node can run any kind of networked app by opening up the right library. Like .net
Also like the .NET Framework, most Node.js applications are going to be HTTP-based in nature
-