Usually, I use the classic starter one.
Expressjs.com
const express = require('express') const app = express() const port = 3000 app.set('view engine', 'ejs') app.use(express.urlencoded({extended: true})) app.use('/', router) app.listen(port, () => { console.log(`This is ${port}`)})
When you use the res.render('anyClassViewName') , Express will search for any .ejs file in your views directory and then render it.
Express.urlencoded is made to handle urlencoded payloads. You can use the { extended: true } option for dealing with any complex objects, arrays, and nested objects, or you can set it to 'false' for simpler data parsing.
Das obige ist der detaillierte Inhalt vonEXPRESS MIT .EJS-VORLAGE KONFIGURIEREN. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!