【发布时间】:2022-01-19 20:00:24
【问题描述】:
我创建了一个仅包含 HTML 文件的项目,我想在 Heroku 上部署它。所以我创建了一个虚拟后端来部署在 Heroku 上,但是当我在 localhost 上运行它时,它会显示一个错误 no such file or directory
错误图片:
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname)));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + 'project.html'));
});
// add other routes below
app.get('/Vaccine2', function(req, res) {
res.sendFile(path.join(__dirname + 'Vaccine2.html'));
});
app.get('/hospital', function(req, res) {
res.sendFile(path.join(__dirname + 'hospital.html'));
});
app.listen(process.env.PORT || 3000);
【问题讨论】:
-
将代码分享为文本,而不是截图
标签: html node.js heroku frontend backend