how are you guys?
Today I need help with my application in Node, I appreciate if someone can help me.
I have my routes set up on my general configuration file, and all my app.gets are rendering files in the folder views, inside the server folder, just like this:
SERVER FOLDER
|
|- VIEWS FOLDER WITH THE SEVERAL EJS TEMPLATES
| |
| -- RESERVATIONS.EJS
|- CONFIGURATIONFILE.JS
So, Just to help you to help me.. i have this get example that are working perfectly:
app.get('/reservas', ensureAuthenticated, function(req, res) {
res.render('reservations');
});
I have this two configurations in my file configuration file:
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
Now, the real problem.
I have a public folder that is a sibling folder of the folder server, and i have this login.ejs and I need to render it in the route /, so i have this:
app.get('/', function (req, res) {
res.render('login');
});
but it is not pulling the file inside the public folder..
If anyone can help me, I appreciate it
All ejs files must be in views folder. Put your login.ejs file into it. And then try
app.get('/', function (req, res) { res.render('login.ejs'); })
or
app.route('/').get(function (req, res, next) { res.render('login.ejs'); })
if you use Express4.