As a newcomer to this project, I currently have an index.html
, record.html
, an application.js
file handling logics and XMLhttp
responses, as well as a style.css
file.
Here is my node-express server which is running locally for now, but will eventually need to be deployed on AWS. I'm wondering about the best way to structure this project. Is it acceptable to place all the HTML, JS, and CSS files in a 'public' folder while keeping the node server files separate? Also, I am not writing any JavaScript in the node server - is this considered good practice? Thank you in advance for your help!
Server:
app.use(express.static(__dirname+'/public'));
app.get('/record', function(req, res) {
res.sendFile(path.join(__dirname + '/public'+ '/record.html'));
});
app.get('/', function (req, res) {
fs.readFile('/index.html', function(error, content) {
if (error) {
res.writeHead(500);
res.end();
} else {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(content, 'utf-8');
}
});
res.send('Hello World');
});
https.createServer({
key: privateKey,
cert: certificate
}, app).listen(8080);
httpServer.listen(8443);