// 导入模块 var app = require('./webServer'); // get请求路由 // app.get('/', function(req, res) { // res.end('HEllo World'); // }) // post请求 ajax带参数 app.post('/test', function(req, res) { res.end(JSON.stringify(req.body)) }) // get请求 ajax带参数 app.get('/test', function(req, res) { res.end(JSON.stringify(req.query)) }) // use 中间件 app.use('/blog', (req, res, next) => { console.log('%s %s', req.method, req.url); next() }) // 模式匹配 app.get('/blog/:id', (req, res, next) => { res.end('hello ' + req.params.id) })