Nodejs study notes

VAR http = request (“http”); var URL = Require (“URL”); function start (route) {// Route .js Route method // service implementation onRequest (request, response) {var pathname = url.parse (Request.URL.). Pathname; route (pathname); // Response.writehead (200, {“Content-Type “:” text / plain “}; response.write (” just a practical hand “); response.end ();} // creation service http.createserver (onRequest) .listen (8888); // port number 8888 Console.log (“Service Launch”); // Output, indicating service launch success} exports.start = start; // Exposing the START method
   
== ======================================

route.js

Function Route (“Request Path is:” + Pathname); // Background View Request Road Difference Request Address} Exports.Route = ROUTE;
  =========================================  
Index.js

VAR Server = Require (“. / server “); var Router = Require (” ./ Route “); server.Start (Router.Route); // Transfer to Start is Router’s route method

                      
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment