1 //node的http服务 2 3 'use strict' 4 var http = require('http') 5 var server = http.createServer(function (request,response) { 6 response.writeHead(200,{'Content-Type':'text/html'}); 7 response.end('我的第一个node Http程序请求
') 8 }) 9 server.listen(8080);10 console.log('Server is running at http://127.0.0.1:8080/')11 12 // 运行结果:13 // $ node hello.js14 // Server is running at http://127.0.0.1:8080/15 // 不关闭命令提示符,打开浏览器:localhsot:8080得到服务器响应内容:我的第一个node Http程序请求