Node.js——基本服務開啓

標註模式ui

var http = require('http');

var server = http.createServer();

server.on('request', function (req, res) {
    res.end('Hello World')
})

server.listen(3000, function () {
    console.log('server is running...')
})

簡寫模式spa

var http = require('http');

http.createServer(function (req, res) {
    res.end('Hello World')
}).listen(3000, function () {
    console.log('server is running...')
})
相關文章
相關標籤/搜索