【发布时间】:2022-08-15 18:38:53
【问题描述】:
我正在尝试为我的 HTML 应用程序创建一个服务器,但是当我转到 localhost:8080/map 时,我得到了Error: Cannot find module \'HTML\'。尽管如此, localhost:8080 页面的主页面工作正常。
我的代码:
const path = require(\'path\');
const port = 8080;
const express = require(\'express\');
const app = express();
app.use(express.static(path.join(__dirname, \'public\')));
app.set(\"view engine\", html);
app.get(\'/\', (req, res) => {
res.render(\'index.html\')
})
app.get(\'/map/\', (req, res) => {
res.render(\'map.html\')
})
var server = app.listen(8080, function () {
console.log(`App listening at http://localhost:${server.address().port}/`)
})
标签: javascript node.js express server