My Node.js website's stylesheet = null
Hello, I didn't found the styleshet, while I defined the stylesheet in style.css file, but when I try to find it in my website, it shows monospaced element like this:
Cannot GET /style.css
Can you help?
you have a static folder that's correct
but you need to host that static folder.
app.use(express.static(__dirname + "/static"));
add that after the const app = express();
Also, have you considered using res.sendFile()
instead of copying and pasting your HTML files??
Still nothing.
you didn't add the code lol @RixTheTyrunt
I actually added, but it didn't work.
I tried res.sendFile("https://nodejam.rixthetyrunt.repl.co/index.html")
but I didn't get anything...
no that's not what I meant
res.sendFile(__dirname + "/index.html")
now make an index.html in the root directory (not in any folders.)
@RixTheTyrunt
What is __dirname
?
the current director you are in @RixTheTyrunt
you should put it in /static
I will put the stylesheet in the folder named static
. OK?
Do I understand you?
Still no stylesheet. Yet.
@RixTheTyrunt you dont fricking need to spam my notification to get your point across
Maybe making
style
attributes will work?Yes! Finally!