我目前正在尝试使用 Parse Web Hosting 为我的 iOS 应用程序设置一个网站。我正在尝试在位于我的网站目录中的网络浏览器中显示 PDF 文件。我正在使用 Express,这是到目前为止发生的事情
var express = require('express');
var app = express();
var fs = require('fs');
// Global app configuration section
app.set('views', 'cloud/views'); // Specify the folder to find templates
app.set('view engine', 'ejs'); // Set the template engine
app.use(express.bodyParser()); // Middleware for reading request body
app.get('/terms', function(request, response){
fs.readFile("/public/terms_conditions_hotspot.pdf", function (err,data){
response.contentType("application/pdf");
response.render(data);
});
});
app.listen();
因此,当我导航到 mysite.parseapp.com/terms
时,我收到 500 错误。
但为了确保一切设置正确,我使用 Parse 的样板代码在您导航到 mysite.parseapp.com/hello
时呈现一条 hello 消息。
app.get('/hello', function(request, response) {
response.render('hello', { message: 'Congrats, you just set up your app!' });
});
这似乎工作正常。有人知道问题是什么吗?
我的目标是将我的 Django Web 应用程序迁移到使用 Parse Web Hosting,主要是因为 Parse 支持 SSL 并提供免费证书,这使得构建此应用程序更便宜(免费)。虽然,我的 Django Web 应用程序的目的是处理 Stripe Connect 重定向并使用 oAuth2,这可能会导致迁移出现问题,因为 Parse 可能不支持某些模块或其他模块。我只是觉得 Parse 的服务非常有限,但我很想看看我能用它做什么。
编辑
所以我运行了 console.log(error)
它返回:
Object [object Object] has no method 'readFile'
readFile肯定是fs('filesystem')包含的方法。那么也许 Parse 中的模块“fs”不是最新的或者引用了不同的模块?
到底是什么?
最佳答案
Parse 似乎没有使用 NodeJS(fs 是一个 Node 模块),尽管它们提供 Express。
参见:https://www.parse.com/questions/loading-nodejs-packages-to-cloud-code
关于javascript - Parse Web 服务器中的文件系统模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29302766/