1. Prepare a folder for the project
2. Create a server.js file under the root directory
3. The file code is as follows
var http = require ("http");
Http.createserver (function (request,response) {
Response.writehead (200,{' content-type ': ' Text/plain ');
Response.End ("Hello world\n")
}). Listen (8080);
Console.log ("Server running at http://127.0.0.1:8080/")
4. Open the project directory with the command line execute the node server.js command
5. Open the corresponding port in the browser to see what we are writing
Varhttp= Require(' HTTP ');http.Createserver(function (Request,Response) {Send HTTP HeaderHTTP Status value: 200:okContent Type: Text/plainResponse.Writehead(200, { ' Content-type ' Span class= "pun" >: ' text/plain ' }); //send response data "Hello World" Response. ' Hello world\n ' listen (8888//terminal prints the following information console. ( ' Server running at http://127.0.0.1:8888/'
Use node JS to create a server upgrade