If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To install EJS and set up the view engine in an Express application, you need to follow these steps:
Copy code
npm install ejs
app.js
file, add the following code to set EJS as the view engine:javascriptCopy code
const express = require('express');
const app = express();
// Set EJS as the view engine
app.set('view engine', 'ejs');
views
directory in the root of your project.index.ejs
file in the views
directory. This will be the default view for your application.index.js
controller, update the response to use the render
method and specify the name of the view to render.javascriptCopy code
const express = require('express');
const router = express.Router();
router.get('/', (req, res) => {
res.render('index');
});
module.exports = router;
index.ejs
file correctly.Note that you can also set the directory where your views are located with the following code:
javascriptCopy code
app.set('views', './views');
This specifies that the views are located in the views
directory, which is in the root of the project.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.