Create a view for home

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 290:- Create a view for home

To create a view for home, follow these steps:

  1. Create a folder called views in the root directory of your project.
  2. Inside the views folder, create a file called home.ejs.
  3. In home.ejs, add the following HTML code:

    htmlCopy code

    <!DOCTYPE html> <html> <head>    <meta charset="UTF-8">    <title>Home Page</title> </head> <body>    <h1>Welcome to the Home Page</h1>    <p>This is the home page of our website.</p> </body> </html>

  4. In your Express app, set EJS as the view engine by adding the following code:

    javascriptCopy code

    app.set('view engine', 'ejs');

  5. In your Express app, add a route for the home page that renders the home.ejs view. For example:

    javascriptCopy code

    app.get('/', (req, res) => {    res.render('home'); });

Now, when you visit http://localhost:3000 in your browser, you should see the content of the home.ejs view.

32. Beginning The Major Project 1

2 Comments

@niteshguptav63
niteshguptav63 Nov 17, 2024 at 1:39 PM

I am not able to access videos from second class and further. I have already completed first class

@niteshguptav63
niteshguptav63 Nov 16, 2024 at 10:56 AM

When will I get my course?

@admin79
admin79 Nov 17, 2024 at 1:29 PM

Now, Your query was resolved.

Frequently Asked Questions About Sciaku Courses & Services

Quick answers to common questions about our courses, quizzes, and learning platform

Didn't find what you're looking for?

help_center Contact Support