I'm new to anything web-development related (I've only been coding using luau for about a year now), and I'm having trouble sending multiple files when my server gets pinged, because I want to have a separate style.css file, as well as different script things.
I've left out MouseDraw.js and style.css, but when I added them directly into index.html they worked, and I can't see them when I inspect element on the website so I think it's just that they aren't being sent.
Is it possible to send them or do I have to just put them in every file?
I would post an image of how it's structured but I'm new so I can't, but it's all under a folder, and then there's just 'Server.js' and a folder called Client, which has everything I want to send to the client.
Server code:
const http = require('http');
const fs = require('fs').promises
const hostname = 'localhost';
const port = 8000;
let loadedPageInfo;
fs.readFile(__dirname + "/Client/index.html") // Get and read the HTML data for this page
.then((contents) => {
loadedPageInfo = contents
})
.catch((error) => {
console.log(`Could not load index.html ${error}`)
})
const server = http.createServer((req, res) => {
res.end(loadedPageInfo || "Error loading");
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Client:
index.html:
<head>
<title>Drawing</title>
<link rel = "stylsheet" type = "text/css" href = "style.css">
</head>
<body>
<h1>Heading One</h1>
<p1>Message from my computer:</p1>
<p2><samp><br><br>File not found.<br>Press F1 to do nothing</samp></p2>
</body>
<script> src = "MouseDraw.js" </script>
</html>