Answer the question
In order to leave comments, you need to log in
Why is it not possible to give css files?
var types = {
'.js': 'text/javascript',
'.css': 'text/css',
'.html': 'text.html',
'.jpg': 'image/jpg'
};
http.createServer(function(req, res) {
fs.readFile('index.html', 'utf-8', function(err, data) {
if (err) {
console.log(err);
} else {
var pathname = path.extname(req.url);
res.writeHead(200, {'Content-type': types[pathname]});
console.log(pathname);
res.end(data);
}
})
}).listen(8080);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question