zoukankan      html  css  js  c++  java
  • 路由模块

    const express = require('express');
    const app = express();
    //1.导入路由对象
    const router=require('./0.1router2.js');
    //2.调用app.use 方法 安装路由器模块
    app.use(router);
    app.listen(2333,()=>{
        console.log('====================================');
        console.log('server runing at http://127.0.0.1:2333');
        console.log('====================================');
    })
    //这是定义了一个路由模块,专门负责创建路由对象,并挂载路由规则
    const express = require('express');
    //调用express.Router
    const router = express.Router();
    const path=require("path");
    router.get("/",(req,res)=>{
        res.sendFile(path.join(__dirname,"./views/index.html"))
    })
    router.get("/index.html",(req,res)=>{
        res.sendFile(path.join(__dirname,"./views/index.html"))
    })
    router.get('/login.html',(req,res)=>{
        res.sendFile(path.join(__dirname,'./views/login.html'))
    })
    router.get("/css/style.css",(req,res)=>{
        res.sendFile(path.join(__dirname,"./views/css/style.css"))
    })
    module.exports=router;
  • 相关阅读:
    2018-div-matrix
    cf663div2
    生成树
    Call to your teacher
    并查集总结
    分组背包
    被3整除的子序列
    多重背包
    12.05
    django生命周期图
  • 原文地址:https://www.cnblogs.com/tuziling/p/10220311.html
Copyright © 2011-2022 走看看