🌐 Nodejs.cn

4.x API 参考

本部分概述了在 Express 4.x 中用于构建网页应用和 HTTP 服务的模块和 API。

🌐 This section provides an overview of the modules and APIs available in Express 4.x for building web applications and HTTP services.

index.cjs
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('hello world');
});
app.listen(3000);

Note

Express 4.x 需要 Node.js 0.10.0 或更高版本

🌐 Express 4.x requires Node.js 0.10.0 or higher.

在 express v4.x 中,你可以使用 express() 函数创建的应用实例来定义路由、配置中间件,以及开始处理 HTTP 请求。该 API 被组织为以下几个部分:

🌐 With express v4.x, you can define routes, configure middleware, and start handling HTTP requests using the application instance created by the express() function. The API is organized into the following sections: