简体   繁体   中英

What does the forward slash mean in app.get('/',function(){…}); in express.js?

我刚刚开始学习express.js,在那我们做app.get('/'。function(){...});,我想知道那是什么意思。我试图研究Google,但实际上无法获得,而不会过于技术化就可以简单地描述它。

Lets say you're running your server on localhost port 8080. Then the root URL of your server is http://localhost:8080 .

Thus when you write

app.get('/', function(request, response) {
  console.log('hi');
})

You're saying

When someone sends an HTTP GET to http://localhost:8080 , I log "hi" into the console.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM