var express = require('express'); //加载模块
app = express(); //实例化express
app.get('/devices',function(req,res){
res.writeHead(200,{'Content-Type':'text/plain'});
res.end('devices');
})
app.get('/devices/:id',function(req,res){
res.writeHead(200,{'Content-Type':'text/plain'});
res.end('devices'+req.param('id'));
})
app.listen(8000); //监听8000端口
console.log('httpd start @8000')
阶段性理解,restful只是一种url风格
扩展,安装express
npm config set registry http://registry.cnpmjs.org //切换源
npm install express //安装express