nd24h_1_0.js // 引入http模块var http = require('http');// 创建一个服务器,并监听127.0.0.1的3000端口http.createServer(function (req, res) { // 设置http响应头 res.writeHead(200, { 'Content-Type': 'text/plain' }); // 返回
// 引入http模块
var http = require('http');
// 创建一个服务器,并监听127.0.0.1的3000端口
http.createServer(function (req, res) {
// 设置http响应头
res.writeHead(200, { 'Content-Type': 'text/plain' });
// 返回响应
res.end('hello world!\n');
}).listen(3000, '127.0.0.1');
// 向标准输出打印文本
console.log("Server running at http://127.0.0.1:3000/");
