html - 在 Heroku 上提供从 NodeJS 以编程方式生成的 HTML 文件

标签 html node.js heroku

我有一个部署在 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/

相关文章:

html - 边框在 CSS 上排列不正确

html - 你能为海报属性提供后备吗?

html - css MIME 类型文本/html 和 AddType 被忽略

javascript - 图表.js :set yAxis point to 0 when there is gap between two dates

javascript - 如何在mongodb数据库上存储setTimeout id?

javascript - 数据库事务并行发生,而不是循环中顺序发生

ruby-on-rails - 由随机词组成的 Heroku 应用程序 url

javascript - 在 MongoDB 中保存和排序日期

ruby-on-rails - "heroku run rake db:migrate"问题

node.js - 赫罗库 | Node.js : No cedar-supported app detected