Description (2017-5-2-10:27:03):
1. Need to install node,http://nodejs.cn/download/
2. After installation, enter node-v in cmd to view the version.
3. Code Foo.js:
Attention:
(1) Http.createserver two parameters, Req.url instead of Res.url, finally must res.end ()!
(2) Server.listen is not listener. 3000 is the port, name it casually. The following is the routing address of their own computer, CMD in the Ipconfig to see a bit.
1 var http = require ("http"); 2 var url = require ("url"); 3 var server = Http.createserver (function(req,res) {4 console.log (" The server received the request "+Req.url); 5 res.end (); 6 }); 7 Server.listen (3000, "192.168.1.150");
4. In the CMD CD to foo.js directory, enter the node foo.js run, the cursor will appear flashing.
5. Enter http://192.168.1.150:3000 in the browser's address bar, which you can see in the console:
node. JS Learning Note (1)--one of the simplest server requests