标题 node第一个服务器程序

来源:互联网 发布:谭浩强c语言第四版答案 编辑:程序博客网 时间:2024/05/01 22:25

 

1.2    正文

1.    新建一个example.js文件

代码如下:

var http=require('http');

http.createServer(function(req,res){

res.writeHead(200,{'Content-Type':'text/plain'});

res.end('Hello,World\n');

}).listen(1337,'localhost');

console.log('Server running at http://localhost:1337/');

2.    之后在cmd下执行

3.     

 

4.    在浏览器中输入http://localhost:1337

0 0
原创粉丝点击