const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  if(req.url!='/favicon.ico'){                        //过滤favicon请求
  console.log('request received!');
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  var name='rod johnson';
  res.end(`Hello
  ${name}`);
 }
}
);

server.listen(port, hostname, () => {
console.log(`服务运行于: http://${hostname}:${port}/`);
});

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-05-18
  • 2021-05-31
  • 2021-12-10
  • 2022-01-13
  • 2021-08-25
猜你喜欢
  • 2021-11-04
  • 2021-08-29
  • 2022-01-01
  • 2021-08-31
  • 2021-06-23
  • 2021-09-08
  • 2021-06-01
相关资源
相似解决方案