I can route on the node where it calls an html page, however the html page has a .js file and when it is called from the error of not finding the JS file.
Can anyone help me?
Structure:
main folder: project
Sub folders: config, js, views
inside config: config.js within js: request.js within views: index.html
config.js:
var express = require('express');
var port = 3000;
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extend : true}));
app.use(bodyParser.json());
app.listen(port);
app.set('views', './views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.use('/public', express.static(__dirname + '/views/'));
module.exports.express = function(){
return app;
}
app.js (it's located in the main folder):
var app = require('./config/config.js').express();
app.get('/',function(req,res){
res.render('index.html');
});