LAB 9 PUG and ExpressJS - sindhusha-t/ASE-Lab-Assignments GitHub Wiki
Assignment 9 ( Using PUG and ExpressJS )
Introduction:
Getting Hands on with PUG and ExpressJS.
Tasks to be done:
- Create a Login Page Using PUG Template Engine.
- On Click of login button display details of user by retrieving from Cookie in NodeJS.
- Load CSS files using express.static() method.
Task-1: Creating a login page using pug template Engine.
- Created an Express Application using Webstorms.
- Installed PUG using the command
npm install pug --save
- In app.js file we have imported express and also the PUG as view engine.
- Specified the required JS files that are used in the application( contains the required routing information)
- Configuring the application to listen on port number 3000
- We have written the PUG file and rendered it from the index.js file.
- After the login form is submitted by the user is redirected to users.js file.
Ran the Application using wither
node app.js
ornodemon
Task-2: Setting Cookie details and retrieving them in the page.
- On Click of the login button -> user credentials are checked with the local JSON file and then user is authenticated.
- The details of the user in the JSON file is saved in the cookie after logging in.
- These cookie values are rendered to the HTML page ( ie users.pug file ) where the user details are displayed in the form of table.
Task-3: Loading the CSS files using express.static function.
Conclusion:
- We have learnt how to create PUG files and render it from the JS files.
- We have learnt how to set the cookie and retrieve them
Team Members:
Sindhusha Tiyyagura (24) Pradeepika Kolluru (12)