learning express step(七)
Route handlers enable you to define multiple routes for a path.
The example below defines two routes for GET requests to the /user/:id path.
The second route will not cause any problems, but it will never get called because the first route ends the request-response cycle.
const express = require('express');
const app = express();
app.get('/user/:id', function (req, res, next) {
console.log('ID:', req.params.id);
next();
},function (req, res, next) {
res.send('User Info');
});
app.get('/user/:id',function (req, res, next) {
console.log(req.params.id);
res.end(req.params.id);
//res.send(req.params.id);
});
app.listen();
result:
C:\Users\admin\WebstormProjects\learning-express-step7>node learning-express-step7.js
ID: id=
ID: id=
web result:

learning express step(七)的更多相关文章
- learning express step(十四)
learning express error handle code: const express = require('express'); const app = express(); const ...
- learning express step(十三)
learning express error handle code: const express = require('express'); const app = express(); app.g ...
- learning express step(十二)
learning express view engine function const express = require('express'); const app = express(); app ...
- learning express step(十一)
learning express.Router() code: const express = require('express'); const app = express(); var route ...
- learning express step(五)
learning express middleware var express = require('express'); var app = express(); var myLogger = ...
- learning express step(四)
learning express route function const express = require('express'); const app = express(); app.get(' ...
- learning express step(九)
router-level middleware works in the same way as application-level middleware, except it is bound to ...
- learning express step(八)
To skip the rest of the middleware functions from a router middleware stack, call next('route') to p ...
- learning express step(六)
code: use application middleware var express = require('express'); var app = express(); app.use(func ...
随机推荐
- 【规律】Farey Sums
[参考博客]: https://blog.csdn.net/meopass/article/details/82952087 Farey Sums 题目描述 Given a positive inte ...
- 21-MySQL DBA笔记-高可用性
第21章 高可用性 本章将为读者介绍单点故障的处理策略,以及单点故障最为主流的解决方案:MySQL数据库切换. 21.1 概述 可用性定义为系统保持正常运行时间的百分比,高可用可以理解为系统可用时间的 ...
- (三)Activiti之第一个程序以及Activiti插件的使用和Activiti表的解释
一.案例 1.1 建立Activiti Diagram图 new -> activiti ->Activiti Diagram,创建一个HelloWorld文件,后缀自动为bpmn,如下图 ...
- java 框架-分布式文件管理系统1FastDFS
https://www.cnblogs.com/chiangchou/p/fastdfs.html
- Keras 训练 inceptionV3 并移植到OpenCV4.0 in C++
1. 训练 # --coding:utf--- import os import sys import glob import argparse import matplotlib.pyplot as ...
- 抓包分析工具web版——capanalysis
1.下载安装 官网上,安装在Ubuntu上 2.使用教程 https://blog.51cto.com/chenguang/1325742
- 使用SQLAlchemy,以及问题处理
https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/0014021031294178 ...
- 版本问题---cuda和tensorflow的版本对应关系
cuda和tensorflow的版本有对应关系 https://tensorflow.google.cn/install/source#linux
- 18 Candidates for the Top 10 Algorithms in Data Mining
Classification============== #1. C4.5 Quinlan, J. R. 1993. C4.5: Programs for Machine Learning.Morga ...
- WCF Endpoint分类
WCF中可以为一个Service配置多个Endpoint 这些Endpoint的分类方法有下面3中 1.全局就一个endpoint,一个接口公开所有的方法,这适合简单的业务场景 2.将endpoint ...