hello,world!

var http = require("http");
http.createServer(function (request, response) {
    response.writeHead(200,  {'Content-Type': 'text/html; charset=utf-8'}); //协议头
    if(request.url != "/favicon.ico") { //清除第二次访问
        console.log("访问");
        response.write("hello,world");
        response.end("访问结束");   //协议尾,如果没有添加,页面一直处于更新状态
    }
}).listen(8000);
console.log("Server running at http://127.0.0.1:8000/");

你可能感兴趣的:(hello,world!)