nodejs系列学习:简单的http请求服务器-----(一)

来源:互联网 发布:ipad取消软件自动更新 编辑:程序博客网 时间:2024/06/01 09:24

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
0 0