Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If the file is large enough, then it can be implemented using streams.
const http = require("http");
const fs = require("fs");
http.createServer(function(request, response){
if(request.url=="/some.doc"){
response.writeHead(200, {"Content-Type" : "application/msword"});
fs.createReadStream("some.doc").pipe(response);
}
else{
response.end("hello world!");
}
}).listen(3000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question