Learn Node.jsnode:
- From the browser run JS, run on the server
- Chrome-based V8 engine that uses V8 virtual machines to parse and execute JS code
To create a simple server:
- To create a server.js file
$ Touch Server.js
- Loading module HTTP using the Require function
- Call the Http.createserver () function to create the server
- Call the Listen method to specify the listening port
- Open the current page on the command line and execute node server.js
$ node Server.js
- Page Open 127.0.0.1: Port, open the page you created
Http.createserver (function (req,rep) { rep.writehead (200,{' content-type ': ' Text/plain '}); Rep.write (' Hello World '); Response.End ();}). Listen ();
The server processes the request:
- Request--------------Requested object (includes: Request query string, parameters, contents, HTTP header, etc.)
- Request.url----------Request Address
- Request.method----Request Action
- Response------------Response Object
- Response.Write ()----response content
- Response.End ()-----End response
Learn node. js