var http = require('http'); //require请求nodejs自带的http模块,并且把它赋值给http变量
//调用http模块的createServer函数,返回一个对象,对象的listen 方法的参数即这个http服务器监听的端口号
http.createServer(function(req,res){
//发送http头部,200:ok,内容类型: 'text/plain'
res.writeHead(200,{'Content-type': 'text/plain'});
//发送响应数据
res.end('hello,http require');
}).listen(9000);
//终端打印
console.log('Server running at http://127.0.0.1:9000/');