0

I have prepared a stand alone Node.js file (shown below). It works as expected. When I ran the code, I gave a command in a DOS window - C:......\folder_name>node file_name.js. While the server was listening, I put a URL in the browser address bar. After I finished the test, I manually terminate the Node.js code using CTRL+C.

Now, I have to do the same thing in a big project/application. And I am lost. I do not know how it works:

  1. To run a big project/application, we simply put a URL in the browser address bar. We do not give a command in a DOS window, such as node file_name.js.

  2. The big project/application runs on the WebLogic server and its port is 7171. Here in my stand alone Node.js code, I define a server and it listens on 8080.

  3. To run a big project/application, I do not manually terminate a specific file.

Please help. Thank you very much.

var http= require('http'),
    url = require('url'), 
    server;

server = http.createServer(function(req, res){
    var path = url.parse(req.url).pathname;

    switch (path){

           case '/lens/v1/ping':
               res.writeHead(200, {'Content-Type': 'text/plain'});
               res.write('The lens route works!\n');
               res.end();

           case '/ecrud/v1/core/ping':
               res.writeHead(200, {'Content-Type': 'text/plain'});
               res.write('The ecrud route works!\n');
               res.end();

           break;

           default: send404(res);
       }
}); 

send404 = function(res){
    res.writeHead(404);
    res.write('Status 404');
    res.end();
};

server.listen(8080);
user2886680
  • 61
  • 3
  • 9

0 Answers0