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/

显示

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM