首页 > Web开发 > 详细

第一个nodejs程序

时间:2018-01-31 13:12:12      阅读:190      评论:0      收藏:0      [点我收藏+]

 

1、用任意文本编辑工具,如notepad++,编写如下代码,保存为test.js文件:

var http=require(‘http‘);
http.createServer(function (request,response){
        response.writeHead(200,{‘Conten-Type‘:‘text/plain‘})
	response.end("Hello,world\n");
}).listen(8887);
console.log(‘Server running at http://127.0.0.1:8887‘) 

  

2、打开cmd,运行该文件,命令 node D:\nodetest\service\test.js,弹出如下页面

技术分享图片

3、在浏览器中输入http://127.0.0.1:8887/,结果如下:

技术分享图片

是不是超级简单呢!!!

第一个nodejs程序

原文:https://www.cnblogs.com/stin/p/8391240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!