Answer the question
In order to leave comments, you need to log in
Why is fs.readFile not reading?
Why does the site's code display instead of the visual page of the site?
var http = require("http");
var fs = require("fs");
http.createServer(function(request, response) {
fs.readFile("index.html", {encoding: "utf-8"}, function(error, file) {
response.writeHead(200, {"Content-type" : "text/plain"});
response.write(file);
response.end();
});
}).listen(8000);
console.log('Server running on port 8000');
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