Node.js Express使用require vs app.get

Node.js Express使用require vs app.get,node.js,express,coffeescript,Node.js,Express,Coffeescript,我知道我的第一行是到名为example的控制器,并使用index函数。 我不太清楚第二行是干什么的。一个比另一个好吗?请给出完整的解释。第一行:app.get”/example,example.index表示如果有人点击URLhttp://localhost:3000/example,然后加载示例文件(大概是上面某个地方的required)并在其上运行index函数 第二行require(“./routes/index”)app只是require在routes文件夹中调用名为index.coff

我知道我的第一行是到名为example的控制器,并使用index函数。
我不太清楚第二行是干什么的。一个比另一个好吗?请给出完整的解释。

第一行:
app.get”/example,example.index
表示如果有人点击URL
http://localhost:3000/example
,然后加载
示例
文件(大概是上面某个地方的
require
d)并在其上运行
index
函数


第二行
require(“./routes/index”)app
只是
require
routes
文件夹中调用名为
index.coffee
的文件,并将
app
作为变量传递。

localhost:3000
几乎是节点app的默认主机:端口。
/example
是因为您指定了
app.get'/example'
# app.get "/example", example.index

# require("./routes/index") app