If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To render pages for Sign up and Sign in, we need to create a new route in our routes directory and define two new controller functions to handle GET requests for the respective pages.
First, we need to create a new file auth.js in the routes directory and define our routes in it.
javascriptCopy code
const express = require('express');
const router = express.Router();
const authController = require('../controllers/authController');
// Sign up page
router.get('/signup', authController.signup_get);
// Sign in page
router.get('/signin', authController.signin_get);
module.exports = router;
Here, we have defined two routes /signup and /signin and specified the corresponding controller functions signup_get and signin_get from authController.
Next, we need to create authController.js in the controllers directory and define the two controller functions.
javascriptCopy code
const signup_get = (req, res) => {
res.render('signup');
};
const signin_get = (req, res) => {
res.render('signin');
};
module.exports = {
signup_get,
signin_get,
};
Here, we have defined two controller functions signup_get and signin_get to render the signup.ejs and signin.ejs views respectively.
Finally, we need to create signup.ejs and signin.ejs views in the views directory with the necessary HTML and EJS code to render the pages.
For example, the signup.ejs view could look like this:
htmlCopy code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Sign Up</title>
</head>
<body>
<h1>Sign Up</h1>
<form action="/signup" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
<br />
<label for="password">Password:</label>
<input type="password" id="password" name="password" required />
<br />
<button type="submit">Sign Up</button>
</form>
</body>
</html>
Similarly, the signin.ejs view could look like this:
htmlCopy code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Sign In</title>
</head>
<body>
<h1>Sign In</h1>
<form action="/signin" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
<br />
<label for="password">Password:</label>
<input type="password" id="password" name="password" required />
<br />
<button type="submit">Sign In</button>
</form>
</body>
</html>
With these files in place, we can now navigate to localhost:3000/signup and localhost:3000/signin in the browser to see the rendered pages for Sign up and Sign in.

When will I get my course?

Now, Your query was resolved.
Quick answers to common questions about our courses, quizzes, and learning platform
Didn't find what you're looking for?
Contact Support
I am not able to access videos from second class and further. I have already completed first class