码迷,mamicode.com
首页 > Web开发 > 详细

node.js 笔记

时间:2017-06-20 10:51:38      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:response   code   发送   头部   浏览器   blog   数据   内容   creates   

:::

node.test.js

var http = require(http);

http.createServer(function (request, response) {

// 发送 HTTP 头部 
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {Content-Type: text/plain});

// 发送响应数据 "Hello World"
response.end(Hello World\n);
}).listen(8888);

// 终端打印如下信息
console.log(Server running at http://127.0.0.1:8888/);

该目录cmd 打node node.test

//cmd 里:
$ node test02.http.js
Server running at http://127.0.0.1:8888/

浏览器:http://127.0.0.1:8888/

 

 

 

 

 

.

node.js 笔记

标签:response   code   发送   头部   浏览器   blog   数据   内容   creates   

原文地址:http://www.cnblogs.com/xiangsj/p/7052892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!