Skip to content

完善中

使用内置的 http 模块搭建服务

js
const http = require("http");
const server = http.createServer((req, res) => {
  console.log("req:", req.method, req.url);
  res.writeHead(200, { "Content-Type": "application/json" });
  res.end(
    JSON.stringify({
      data: "Hello World!",
    })
  );
});
server.listen(8000, () => {
  console.log("running is 8000");
});