2018-11-09 09:43:03   Visit  0

简单服务

var http = require(\'http\');

http.createServer(function (request, response) {

    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {\'Content-Type\': \'text/plain\'});

    // 发送响应数据 \"Hello World\"
    response.end(\'Hello World\\n\');
}).listen(8888);

// 终端打印如下信息
console.log(\'Server running at http://127.0.0.1:8888/\');

 

http静态文件服务

安装http-server

npm install http-server -g

 

启动服务

http-server -p 8089

 

 

 

相关文章:

  • 2021-09-08
  • 2021-05-23
  • 2021-08-01
  • 2021-12-12
  • 2021-04-30
  • 2021-07-07
  • 2021-05-15
猜你喜欢
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案