zoukankan      html  css  js  c++  java
  • 中间件

    
    
    const express = require('express')
    
    const app = express()
    
    // 定义一个中间件函数
    // const mw = (req, res, next) => {
    // console.log('最简单的中间件函数')
    // 把流转的关系转交给下一个中间件或者路由
    // next()
    // }
    
    // 将mw注册为全局生效的中间件
    // app.use(mw)
    
    
    // 简化全局中间件
    app.user((req, res, next) => {
        console.log('最简单的中间件函数')
        next()
    })
    
    // 创建路由
    app.get('/', (req, res) => {
        res.send('Home page.')
    })
    
    app.get('/user', (req, res) => {
        console.log('调用这个user路由')
        res.send('/User page')
    })
    // listen监听
    app.listen(80, () => {
        console.log(" running http://127.0.1.1")
    })  
    
    
    
     
  • 相关阅读:
    2019年8月20日 item系列
    变量和字符
    python命名规则
    五大常用算法之贪心算法
    过河卒
    组成三位数
    编码问题
    FatMouse' Trade
    A Boring Game
    螺旋矩阵
  • 原文地址:https://www.cnblogs.com/lblblibin/p/13546694.html
Copyright © 2011-2022 走看看