node原生服务器
/*
 * @Descripttion:
 * @version:
 * @Author: jack
 * @Date: 2022-03-07 22:18:09
 * @LastEditors: jack
 * @LastEditTime: 2022-03-07 22:37:57
 */
// 导入http模块
const http = require("http");
const app = http.createServer((req, res) => {
  // req:请求对象:一些参数以及请求体
  // res:响应对象:返回给前端的数据
  // 设置响应头
  res.writeHead(200, { "Content-Type": "text/plain;charset=utf-8" });
  // 设置返回数据
  res.end(`欢迎学习node.js`);
});
const port = 9990;
app.listen(port, () =>
  console.log(`监听了9990,成功,运行在  http://127.0.0.1:${port}`)
);
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号