Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

node how to stop NodeJS server process

const http = require("http");

const server = http.createServer(function (req, res) {
  const url = req.url;

  if (url === "/") {
    // do a 200 response
    res.writeHead(200, { "Content-Type": "text/html" });
    res.write("<h1>Hello World!<h1>");
    res.end();
  }
});

server.listen(3000, function () {
  console.log("server started at port 3000");
});
Source by sebhastian.com #
 
PREVIOUS NEXT
Tagged: #node #stop #NodeJS #server #process
ADD COMMENT
Topic
Name
8+8 =