How the node+express project render renders templates for subdirectories under the views directory

create a folder back under views, create a template under the back folder, index.jade, defines template routing, and access template 404.

the directory structure is as follows

app.js code is as follows

var createError = require("http-errors");
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");

var indexRouter = require("./routes/index");
var usersRouter = require("./routes/users");

var app = express();

// view engine setup
app.set("views", path.join(__dirname, "views"));  //
app.set("view engine", "jade");  //

app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));

app.use("/", indexRouter);
app.use("/users", usersRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get("env") === "development" ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render("error");
});

module.exports = app;

index.jade under the users.js route definition back folder

var express = require("express");
var router = express.Router();

/* GET users listing. */
router.get("/", function(req, res, next) {
    res.send("respond with a resource");
});
router.get("/back", function(req, res, next) {
  res.render("back/index",{title:""});
});


module.exports = router;

by the way, post the index.js code

.
var express = require("express");
var router = express.Router();


var  MongoClient = require("mongodb").MongoClient;
var  DB_CONN_STR = "mongodb://localhost:27017/calutar";
var insertData = function (db,data,callback) {
    var collection = db.collection("calutar");
    collection.insert(data,function (err,result) {
        if(err){
            console.log("Error"+err);
            return;
        }
        callback(result);
    })
}
var getData = function (db,callback) {
    var collection = db.collection("calutar");
    collection.find().toArray(function (err,result) {
        if(err){
            console.log("Error:"+err);
            return;
        }
        callback(result)
    })
}

/* GET home page. */
router.get("/", function(req, res, next) {
  res.render("index", { title: "" });
});
router.get("/history",function (req,res,next) {
    res.render("history", { title: "" });
});

//  
router.post("/foot",function (req,res) {
    //  
    var accountTemp = req.body.account; //
    var monthTemp = req.body.month/1; //
    var ageTemp = req.body.age/1; //
    var sexTemp = req.body.sex; //
    var termLimitTemp = req.body.termLimit; //
    var typeTemp = req.body.type; //


    var ageLong; // -- 
    if(sexTemp == 0){ //=0=1
        ageLong = (60 - ageTemp)*12;
    }else if(sexTemp == 1){
        ageLong = (55 - ageTemp)*12;
    }
    var maxGetTemp = accountTemp*8+monthTemp*ageLong;  // -- 
    var monthReturnTemp;
    if(typeTemp==0){ //
        monthReturnTemp = maxGetTemp/ageLong;
    }
    else if(typeTemp==1){ //
        monthReturnTemp = maxGetTemp/ageLong+3000;
    }
    var dateTemp = new Date().getTime();
    var query_doc = {account:accountTemp,month:monthTemp,age:ageTemp,sex:sexTemp,termLimit:termLimitTemp,type:typeTemp,maxGet:maxGetTemp,monthReturn:monthReturnTemp,date:dateTemp}
    MongoClient.connect(DB_CONN_STR,function (err,db) {
        insertData(db,query_doc,function (result) {
            console.log("", result);
            db.close();
        })
    });
    var json ={code:0,msg:"request is ok",data:{maxGet:maxGetTemp,monthReturn:monthReturnTemp}};
    res.send(json);
});
router.post("/head",function (req,res) {
    MongoClient.connect(DB_CONN_STR,function (err,db) {
        getData(db,function (result) {
            console.log("",result);
            res.send({code:0,msg:"request is ok",data:result})
            db.close();
        })
    })
})
module.exports = router;

rookie beginners, very confused, whether there is a great god to solve my problem, thank you

Apr.03,2021

app.set ('views', [path.join (_ dirname,' views'), path.join (_ dirname, 'views/back')]);

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1beb0c4-31a4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1beb0c4-31a4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?