我有一个部署在 Heroku 上的 ruby 脚本,它会在 /html
下的 apps 文件夹下生成某些 HTML 文件。
我正在尝试从 NodeJS 应用程序提供这些文件,该应用程序位于同一应用程序下。
我的 index.js
看起来像这样:
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/html'));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', function(request, response) {
var html = fs.readFileSync(__dirname+'/html/mytest.html', 'utf8')
response.send(html);
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
现在,即使我正在根据每个请求读取文件。我正在获取我在 github 存储库中提交的 html 文件的虚拟副本。
有什么方法可以访问这个新覆盖的 html 副本吗?
谢谢
最佳答案
Heroku 文件系统大多是只读的,但有一些异常(exception)。
请查看this answer真正考虑使用 S3,这似乎是一个非常简单的解决方案。
关于html - 在 Heroku 上提供从 NodeJS 以编程方式生成的 HTML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41904778/