Home > Web Front-end > JS Tutorial > body text

CONFIGURE EXPRESS WITH .EJS TEMPLATE

WBOY
Release: 2024-09-03 13:32:21
Original
974 people have browsed it

CONFIGURE EXPRESS WITH .EJS TEMPLATE

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}`)})
Copy after login

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.

The above is the detailed content of CONFIGURE EXPRESS WITH .EJS TEMPLATE. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!