DEV Community

Stillnoturdad
Stillnoturdad

Posted on • Updated on

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', 'pug')
app.use(express.urlencoded({ extended: true }))
app.use('/', require("./routers"))

app.listen(port, () => {
    console.log(`YOU'RE IN ${port}`)
})
Enter fullscreen mode Exit fullscreen mode

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 to deal with complex objects, arrays, and nested objects, or you can set it to 'false' for simpler data parsing.

Top comments (0)