I'm running a local copy of nodejs and have taken some code which runs a web service and references a local index.html
on startup. This service is running locally on my desktop.
I've been playing about with CSS, and have found no matter what I do, the style sheet does not load, taking the configuration from the style sheet and dropping this within some <style>
elements works fine. But for some reason or another, it's not reading the stylesheet.
Location of style sheet is: c:program files
odejsdefault.css
HTML code:
<link rel="stylesheet" type="text/css" href="default.css" />
This is in the same location as index.js
, index.html
. Has permissions etc to read file.
Any ideas why this potentially may not be loading.
index.js
code:
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res){
fs.readFile('index.html', function (err, data){
res.writeHead(200, {
'Content-Type': 'text/html',
'Content-Length' : data.length
});
res.write(data);
res.end();
});
}).listen(1337, '127.0.0.1');
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…