nodejs系列学习:简单的http请求服务器—–(一)
首先安装啊什么的就跳过了
1、编写文件server.js
var http = require('http');
var server= http.createServer(function(req,res){
console.log(res);
res.write('hello');
res.end();
});
server.listen(9001);
说明:node通过require的方式引入http模块;为什么这么写看文档http://nodeapi.ucdok.com/#/api/
2、开启服务器
node ./http.js
3、浏览器访问
http://localhost:9001