简体   繁体   中英

Receiving Cannot GET/ Error NodeJS and Express

I'm learning how to use NodeJS and Express, and I'm having trouble loading pages using express. I'm able to load static pages (index.html works fine), but having trouble with anything dynamic; in this case, I keep receiving the error "Cannot GET /store.html". Would someone be able to explain what is happening?

server.js

app.set('view engine', 'ejs')
app.use(express.static('public'))

app.get('/store', function(req, res) {
    res.render('store.ejs', {
        FOO: foo
    })
})

file structure

server.js
public
    index.html
views
    store.ejs

您应该使用 /store 来访问 store.ejs 模板而不是 /store.html

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