Thursday, 6 September 2018

I need help understanding node.js route handling and this index.js file that is part of the heroku getting started file.

this is what is in the index.js file:​const express = require('express') const path = require('path') const PORT = process.env.PORT || 5000 express() .use(express.static(path.join(__dirname, 'public'))) .set('views', path.join(__dirname, 'views')) .set('view engine', 'ejs') .get('/', (req, res) => res.render('pages/index')) .listen(PORT, () => console.log(`Listening on ${ PORT }`)) ​What exactly is going on here, and could I add to this code (alternatively making a new file like an app.js file) that would allow me to have more than just one web page in this application. I have seen a lot of tutorials but I don't fully understand exactly what is going on here.

Submitted September 06, 2018 at 09:43PM by OmegaLiar

No comments:

Post a Comment