nodejs引入外部模块

// 表示引入http模块
var http = require('http');
// 接收两个参数,一个是request和response
// request 获取url传过来的信息
// response 给浏览器响应信息
http.createServer(function (request, response) {
    // 设置响应头
  response.writeHead(200, {'Content-Type': 'text/plain'});
//   页面上输出一句话,并且结束响应
  response.end('Hello World');
}).listen(8081);端口

console.log('Server running at http://127.0.0.1:8081/');

在浏览器中输入 http://127.0.0.1:8081/

显示

 

posted @ 2020-06-11 14:32  卡卡刘  阅读(1020)  评论(0)    收藏  举报