Question
1. Create a new folder for your task 2. Open up NPM inside the folder you just created 3. Add Express with pug to the
1. Create a new folder for your task 2. Open up NPM inside the folder you just created 3. Add Express with pug to the project using the express --view=pug command 4. Create a new folder called APP_SERVER 5. Create a models folder and a controllers folder inside APP_SERVER 6. Move the views folder and the routes folderfrom the root folder to inside the APP_SERVER folder 7. Open app.js and update it so it can find your views folder (which we just moved to the APP_SERVER folder) with: app.set('views', path.join(__dirname, 'app_server', 'views')); 8. Change the indexRouter variable to: const indexRouter = require('./app_server/routes/index'); 9. Make the same change you just did for indexRouterfor the userRouter variable 10. Open the controllers folder and create a new file called main.js 11. Add this code snippet to your main.jsfile: 12. Update index.jsin the routes folder creating a const ctrlMain which requires the new controller located at ../controllers/main 13. Modify the router.get function by removing the callback function (the second parameter function(req, res, next){})and replacing it with a reference to your controllers index function (See Listing 3.2 in the textbook) 14. Update the application so it says your name instead of Express by changing the main.jsfile 15. Install the dependencies using npm install 16. Run the server with npm start and show your professor the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started