var http = require('http');//http依赖var hostname = '127.0.0.1';//本地var port = 3000;//端口var server = http.createServer(function(req, res) { res.statusCode = 200;//状态码 res.setHeader('Content-Type', 'text/plain');//服务器的头 res.end('Hello World\n');//输出的内容});server.listen(port, hostname, function(){ console.log('run');//执行成功的回调});