First application for node.js
First application for node.js
没有人是一座孤岛 发表于1年前
First application for node.js
  • 发表于 1年前
  • 阅读 11
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

Before start you need the following two saftwares available on your computer,a>Text Editor b>The Node.js binary  installables.

Download latest version of Node.js installable archive file from  https://nodejs.org/download/

creating node.js aplication:

step1:Inport Require Module

var http = require("http");

step2:create server

Read request and return response

http.createServer(function (request, response) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});
   
   // Send the response body as "Hello World"
   response.end('Hello World\n');
}).listen(8081);

// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');

step3:Testing Request&Response

$ node main.js
Server running at http://127.0.0.1:8081/

Console Output “Hello World” 

Congratulations, running success;

共有 人打赏支持
粉丝 2
博文 5
码字总数 1362
×
没有人是一座孤岛
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: