Node.js
iamfjg
这个作者很懒,什么都没留下…
展开
-
The Node Shell
Node shell 常常也叫做 Node REPL——REPL代表Read-Eval-Print-Loop。 启动:在 shell 中输入 node 就可以了 client:node marcw$ node > 下面输入了一些代码: > console.log("Hello World"); Hello World! undefi...原创 2015-07-31 22:28:53 · 51 阅读 · 0 评论 -
Your First Web Server
现在,你已准备好编写有点有趣的东西了,就比如我们要写一个小的web server。幸运的是,Node 让这样的任务变得很简单。把下面的代码保存到一个叫 web.js 的文件中: var http = require("http"); function process_request(req, res) { var body = 'Thanks for calling!\n'...原创 2015-07-31 23:08:06 · 115 阅读 · 0 评论 -
运行多个 Node 服务器
购买若干服务器很容易,然后在这些服务器上运行一些 Node 进程。But how can these distinct servers be coordinated such that they form part of a single application? One aspect of this problem concerns clustering multiple ident...原创 2015-08-31 10:12:42 · 1803 阅读 · 0 评论 -
用Connect——HTTP中间件模块实现一个web服务器
虽然Node.js中的http核心模块可以用来实现web服务器,但要做很多工作,例如要检测每个文件的content type 因此我们决定用Connect模块,非常流行的Express web框架就是建立在Connect之上的 一个快速的静态web服务器: var connect = require('connect'); connect.createServer( c...原创 2017-03-22 21:22:10 · 297 阅读 · 0 评论 -
使用Node包管理器
Node中的内置模块被称为Node核心。虽然Node的核心囊括了许多有用的功能,你同样很有可能需要用到社区创建的一些功能。 下面将学习如何利用 npm 来查找插件、查看插件的文档,以及插件的源码。 我系统上没有npm: 如果你已经安装了Node,则npm应该也装好了。可以在命令行输入 npm 来验证一下。如果不行,安装方法如下: cd /tmp git clone git...原创 2015-12-31 10:42:09 · 100 阅读 · 0 评论