DEV Community

Stillnoturdad
Stillnoturdad

Posted on • Edited 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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more