let express = require('express');
let app = express();
app.get('/', function(req, res) {
res.sendFile('main.html', { root : __dirname})
});
app.listen(9000, function(){
console.log('Listening on port 9000');
});
This block of code is functioning well. The application requires Express and assigns it to the variable 'app'.
It then sends an HTML file (located in the same directory) using res.sendFile within the app.get method.
In the HTML file, there is a reference to a CSS file in the same directory, but nothing seems to be loading.
<link rel='stylesheet' type='text/css' href='mainstyle.css'>
I am wondering how to properly send the CSS file to the browser for usage since res.sendFile isn't working as expected.
Any suggestions would be greatly appreciated.