This seems like a ridiculous thing to be hung up on, but I would like to display html files from within app.get() methods. It seems like every answer I've come across uses the solution app.use(express.static(__dirname + '/public'));, but then that does not allow for logic from the server.
What I would like to do, is have my .html files be rendered by express, so I can keep some basic logic:
app.get('/', function(res, req) {
if (condition) {
res.render('this.html');
}
else {
res.render('that.html');
}
}
It seems so silly to me that this is only meant for template files, and that I must not be seeing something simple to make this work.
Edit: Using sendFile does not seem to allow the HTML to include external files, javascript / css.
You can use res.sendfile() (res.sendFile() for new version) to render html files.
Update for question in comment:
You can include your css and javascript files in the html file (you might need to specify the paths for your resources correct to get them loaded):
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<script src="myscripts.js"></script>
</head>