Node.js學習001-hello world

Node.js學習001-hello world

Node.js學習001-hello world

var http = require('http');

http.createServer(function (request, response) {

    // 發送 HTTP 頭部 
    // HTTP 狀態值: 200 : OK
    // 內容類型: text/plain
    if(request.url != "/favicon.ico"){
        response.writeHead(200, {'Content-Type': 'text/plain'});
        console.log("訪問");
        response.write("Hello world!")
        response.end('');
    }
}).listen(8888);

// 終端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章