send files with requests instead of serving the whole repertory in static

This commit is contained in:
2025-02-08 18:18:15 +01:00
parent ad0fcca2ee
commit 8250e4f98f
4 changed files with 19 additions and 5 deletions

View File

@@ -1,9 +1,14 @@
const path = require('path');
const mainController = {
root: (req, res) => {
res.json({
message: "Hello, World!",
});
res.sendFile(path.resolve(__dirname + '/../public/index.html'));
},
style: (req, res) => {
res.sendFile(path.resolve(__dirname + '/../public/style.css'));
},
script: (req, res) => {
res.sendFile(path.resolve(__dirname + '/../public/script.js'));
}
};