express
express.static()
routing 路由
为了提供对静态资源文件(图片、csss文件、javascript文件)的服务,请使用Express内置的中间函数 express.static 。 传递一个包含静态资源的目录给 express.static 中间件用于立刻开始提供文件
app.use('/public', express.static('public'));
Routing is to determine the response based on the request URI and method • Virtual files and paths can be specified in the URL • The path specified by the URL is simply parsed as a string • In Express, routing depends on the HTTP method app.METHOD(route_path, callback); METHOD can be one of get, post, put, delete, all
node第三方模块body-parser的urlencoded方法
extended: false:表示使用系统模块querystring来处理
Node.js GET/POST请求
在很多场景中,我们的服务器都需要跟用户的浏览器打交道,如表单提交。
表单提交到服务器一般都使用 GET/POST 请求。