首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Node.js 示例

Node.js示例

第一个服务器的例子就从 “Hello World” 开始:

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

把代码拷贝到example.js文件里,使用node程序执行:

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

在该Node.js官方文档中的所有的例子都可以使用上述方法执行。

扫码关注腾讯云开发者

领取腾讯云代金券