New in node and try to run an HTML page using Express and EJS
app.set('views', __dirname + '/views'); app.engine('html', require('ejs').renderFile); //load up index file app.get('/', function(req, res){ res.render('index.html'); });
However, HTML contains some relative JS script paths.
<html> ....more... <script src="js/libs/jquery.js"></script> <script src="js/libs/underscore.js"></script> <script src="js/libs/backbone.js"></script>
If I run my HTML page through my original "localhost / myProject", everything works fine. However, if I run my file through Node, which is set to "localhost: 8080"
app.server.listen(8080);
Then it no longer finds the directory / js. Is there some kind of configuration that I am missing, or should I go this way?
Update : Just Found This
app.use(express.static( __dirname + '/public' ));
may be what i'm looking for though i need to do refactoring
source share