var express = require('express');
var app = express();
app.use(express.static('./public'));
// http://localhost:8000/
app.get('/',function(req,res){
res.send('hello\n');
});
app.listen(8000,function(){
console.log('express running on http://localhost:8000');
});
// http://localhost:8000/post/add
// http://localhost:8000/post/list
var Router = express.Router();
Router.get('/add',function(req,res){
res.send('hello\n');
});
Router.get('/list',function(req,res){
res.send('hello\n');
});
app.use('/post',Router);
// get post method requset http://localhost:8000/haha
app.route('/haha')
.get(function(req,res){
res.send('route /haha get \n');
})
.post(function(req,res){
res.send('route /haha post\n');
});
//http://localhost:8000/news/123
app.param('newId',function(req,res,next,newId){
req.newId = newId;
next();
});
app.get('/news/:newId',function(req,res){
res.send('news: ' + req.newId + ' get \n');
});
var app = express();
app.use(express.static('./public'));
// http://localhost:8000/
app.get('/',function(req,res){
res.send('hello\n');
});
app.listen(8000,function(){
console.log('express running on http://localhost:8000');
});
// http://localhost:8000/post/add
// http://localhost:8000/post/list
var Router = express.Router();
Router.get('/add',function(req,res){
res.send('hello\n');
});
Router.get('/list',function(req,res){
res.send('hello\n');
});
app.use('/post',Router);
// get post method requset http://localhost:8000/haha
app.route('/haha')
.get(function(req,res){
res.send('route /haha get \n');
})
.post(function(req,res){
res.send('route /haha post\n');
});
//http://localhost:8000/news/123
app.param('newId',function(req,res,next,newId){
req.newId = newId;
next();
});
app.get('/news/:newId',function(req,res){
res.send('news: ' + req.newId + ' get \n');
});