From 2af19d4b7930df8789bbad33a78a8ba0ba82f1a2 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 2 Jul 2022 19:50:33 +0530 Subject: [PATCH] applying for Each loop on array list --- index2.js | 32 ++++++++++++++++++++++++++++++++ views/profile.ejs | 27 +++++++++++++++++++-------- 2 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 index2.js diff --git a/index2.js b/index2.js new file mode 100644 index 0000000..a6152ac --- /dev/null +++ b/index2.js @@ -0,0 +1,32 @@ +const express = require('express'); + + +const port = 8000; +const app = express(); + +//Telling Node Js that ue are using view engine of ejs +app.set('view engine' , 'ejs'); + +app.get('/' , (req , res) => { + res.render('home'); +}) + +app.get('/profile' , (req , res) => { + user = { + name:'Anil', + email:'anil@gmail.com', + city:'Noida', + skills:['HTML' , 'Css' , 'Js' , 'Node Js' , 'Java'] + } + res.render('profile' , {user}); +}); + + +app.listen(port , (err) => { +if(!err){ + console.log(`Server is running on the port::${port}`); +} +}); + + + diff --git a/views/profile.ejs b/views/profile.ejs index 33fc541..3344a67 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -1,15 +1,26 @@ - - - - + + + + Profile page - - + + +

Profile Page

Welcome <%= user.name %>

Email:<%= user.email %>

City:<%= user.city %>

- - \ No newline at end of file +

Skills:<%= user.skills %>

+ + + + + +