Answer the question
In order to leave comments, you need to log in
Why does fs.open() not send html?
Good evening, please advise.
1) Why, when opening an html file, css is not opened along with it?
2) Why doesn't he open the page through fs.open?
var file = fs.open("index.html", "r");
res.writeHead(200,{"Content-type":"text/html"});
res.write(file);
res.end();
var http = require('http');
var fs=require('fs');
var httpServer = http.createServer(function (req, res) {
var data = fs.readFile("index.html", function(err, file) {
res.writeHead(200,{"Content-type":"text/html"});
res.write(file);
res.end();
});
}).listen(8000);
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="main">,/div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
1) Why, when opening an html file, css is not opened along with it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question