Very superficial, purely memo.
//built-in HTTP module, provides HTTP server and client functionality (path module is also built-in module, MIME is add-on module)varHttp=require ("http");//Create a server, create an HTTP server to invoke the Http.createserver () function, which has only one parameter, is a callback function that the server calls once each time it receives an HTTP request. Each HTTP request received by the server will trigger the request function with the new requests and response objects. varServer=http.createserver (function(REQ,RESP) {Console.log ("Request Address is:" +Req.url); //resp.statuscode=200;//Status Code 200, indicating success //Resp.setheader ("Content-type", "text/plain;charset=utf-8");//Returns the MIME type of the content, Charset=utf-8 ensures that the Chinese is not garbled //the compact form aboveResp.writehead (200,{"Content-type": "Text/plain;charset=utf-8"}); Resp.write ("Hello!" said the man. Nodejs "); Resp.end ();//Response Object End Response});//Server starts operation listening PortServer.listen ("localhost",function() {Console.log ("Server started operation, listening on port 3000 ...");});
The effect is:
Node. JS Minimalist Introduction HelloWorld Server Example