const http = require('http');

const server = http.createServer();

  // 绑定客户端请求事件
  // on => 绑定事件
  // request => 请求事件
  // 为 nodejs 系统调用 (因为是nodejs调用)
  // 给server对象绑定request事件
 
  server.on('request',function(req,res){
 
 
  // 前台请求的方式
  if(req.method == 'GET'){
    console.log('GET请求')
  }

  if(req.method == 'POST'){
    console.log('POST请求')
  }
 
  res.end()
});

server.listen(1234,()=>{
console.log('this server is runing on 1234')
});

// 必须加上分号,上面的也是。也就是之前bug出现的原因

相关文章:

  • 2021-09-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-01-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-07-07
  • 2021-04-02
  • 2021-09-19
相关资源
相似解决方案