I’m trying to learn node.js. I made a http server:
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "test/html"});
response.write("Hello World");
response.end();
}).listen(8888);
When I go to localhost:8888/, the page suppose to say “Hello World” but instead, a files download that has “Hello World” in it. Is this what is suppose to happen?
It looks like you have set the Content-Type to
test/htmlrather thantext/html. Your browser doesn’t know how to handletest/htmlso it gives you the option to download the file.