node express route demo
来源:互联网 发布:java hello world 代码 编辑:程序博客网 时间:2024/06/09 19:43
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');
});
阅读全文
0 0
- node express route demo
- node.js express 官方Route使用说明
- node.js的express框架写个小的服务器demo
- express for node 路由route几种实现方式的思考
- 分针网—每日分享:express for node 路由route几种实现方式的思考
- node-express
- node express
- node express
- node-express
- nodejs express route 的用法
- nodejs express route 的用法
- NodeJS搭建博客系统(四)使用模版引擎(node+express+ejs做的一个demo)
- Node(24) Express Project
- Node(23) Express
- Node.js express路由
- Node.js Express
- node.js+eclipse+express
- Node.js Express框架
- <s:select 下拉 选择 登录 用户名 -- ajax ,json
- 机房重构之修改密码窗体所遇到的问题(1)
- 我的电路实践
- 牛腩新闻发布系统小知识集锦
- spring-cloud中config配置中心使用(基于eureka的高可用)
- node express route demo
- signalr
- fail-fast 与 fail-safe 机制有什么区别
- Java SecurityManager相关概念理解
- 周末训练笔记+UVA138+HDU2973【筛素数】【威尔逊定理】
- SpringBoot事务管理
- Java虚拟机的基本结构
- hdoj 1004 Let the Balloon Rise(map)
- 用BASS库重采样音频