Answer the question
In order to leave comments, you need to log in
Running a local site via node server?
I immediately apologize for such ridiculous questions, but I didn’t have to work with servers before and please explain how to run my local site through the node server. I have a directory with index.html and server.js files with code
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World 11");
response.end();
}).listen(8888);
Answer the question
In order to leave comments, you need to log in
how to open my file in this server nowThis is called serve static content. By default, there is no such functionality, but it is very simple to do it: read the file on the appropriate request and send it via response.write. To make it even easier and with goodies, there is a serve-static package , everything is described in the examples there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question