text/plain 会将响应体完全的当成文本输出。
text/html 会把响应体解析成html标签,进行解析的工作
text/text 会有点类似于一个文件下载。
//这个是引入require模块
var http = require("http");
http.createServer(function(request,response){
//发送HTTP头部
//HTTP状态值 200,ok
//内容类型 text/html 会将文件的content-type设置为text/html的形式。浏览器会用到HTML解析器
//内容类型 text/plain 这句话的意思是浏览器获取到此消息的时候不会处理
//下两行是方法一
// response.writeHead(200,{"Content-Type":'text/html'});
// response.end('<h1>Hello World</h1>\n');
//这两行是方法二
response.writeHead(200,{"Content-Type":'text/plain'});
response.end('<h1>Hello World</h1>\n');
}).listen(8888,"127.0.0.1");
console.log('Sever is running');