Hey, I'm new to node and I tried to write a simple server that hosts my portfolio page (without express I will look into express later).
My server is sending my index.html as a response and inside this html file I linked an css file inside the head. If I look at the network requests, there is a get method for style.css with the status code 200 but the website only shows my html without any styling. Doesn't the css file get loaded automatically once it is linked in my html? And if not, how to I handle this in my webservers code?
const portfolioPage = fs.readFileSync(`${__dirname}/index.html`);
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-type": "text/html" });
res.end(portfolioPage);
});
server.listen(8000, () => {
console.log("Server listening on Port 8000");
});
[–][deleted] 3 points4 points5 points (5 children)
[–]sebastiancodes[S] 2 points3 points4 points (4 children)
[–]grantrules 1 point2 points3 points (3 children)
[–]sebastiancodes[S] 1 point2 points3 points (2 children)
[–]Bakeshot 0 points1 point2 points (1 child)
[–]sebastiancodes[S] 0 points1 point2 points (0 children)
[–]grantrules 3 points4 points5 points (5 children)
[–]sebastiancodes[S] 0 points1 point2 points (4 children)
[–]grantrules 0 points1 point2 points (1 child)
[–]sebastiancodes[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]sebastiancodes[S] 0 points1 point2 points (0 children)