Node.js——基本服务开启
标注模式
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...') })
简写模式
var http = require('http'); http.createServer(function (req, res) { res.end('Hello World') }).listen(3000, function () { console.log('server is running...') })