欢迎阅读『Tag标签列表』

路由模块

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;

 

posted @ 2019-01-04 15:49  兔子零-A酱  阅读(463)  评论(0编辑  收藏  举报