建立一个简单的web server

  1. 导入http模块

    const http = require('http');
    
  2. 创建server

    const server = http.createServer((req, res) => {
      res.end("Hello form the server!");
    });
    
  3. 开启server

    server.listen(8000, "127.0.0.1", () => {
      console.log("Listening to requests on port 8000.");
    });
    
posted @ 2022-06-18 02:46  kihyun  阅读(49)  评论(0编辑  收藏  举报