"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > CONFIGURE EXPRESS WITH .EJS TEMPLATE

CONFIGURE EXPRESS WITH .EJS TEMPLATE

Published on 2024-09-18
Browse:284

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}`)})

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.

Release Statement This article is reproduced at: https://dev.to/hopelesscoder/configure-express-with-ejs-template-1ach?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3