Node.js API —— Synopsis(概要)

// 说明
    Node API 版本为 v0.10.31。
    中文参考:http://nodeapi.ucdok.com/#/api/ 
    本段为博主注解。

目录

● 概要

概要

    一个以 ’Hello World‘ 做为响应的以 Node 编写的 web 服务器
1 var http = require('http'); 2  
3 http.createServer(function (request, response) { 4     response.writeHead(200, {'Content-Type': 'text/plain'}); 5     response.end('Hello World\n'); 6 }).listen(8124); 7 
8 console.log('Server running at http://127.0.0.1:8124');

    要运行服务器,须要将代码输入一个名为 example.js 的文件并经过 node 程序执行node

> node example.js Server runing at http://127.0.0.1:8124/

    文档中全部的例子均可以相似地运行。 web

相关文章
相关标签/搜索