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;
  • 相关阅读:
    自定义博客园代码格式
    metaWeblog Test
    STM32 USB复合设备编写
    C数组下标越界
    使用powershell批量修改文本为utf8
    在QtCreator中使用doxygen
    29.内存的基础知识
    28.时钟初始化
    27.点亮led的操作
    26.核心初始化之关闭MMU和cache
  • 原文地址:https://www.cnblogs.com/tuziling/p/10220311.html
Copyright © 2011-2022 走看看