问题描述
我正在尝试在 example.com 上使用 socket.io 设置一个基本的 websocket,它在 VPS 上运行。对于内容,我有一个 index.mjs 文件和一个 index.html。我在 mjs 中调用 html:
directory = getDirectory("Choose a Directory");
resultFilename = directory + Dialog.getString() + ".csv";
f = File.open(resultFilename);
D = getResult("B",nResults() - 1);
for (i = 0; i < nResults() - 2; i++) {
ai = getResult("A",i);
bi = getResult("B",i);
ci = ai - D;
// should the line above should be ci = bi - D;
print(f,d2s(ai,6) + " \t" + d2s(bi,6) + " \t" + d2s(ci,6));
}
File.close(f);
在 /var/www/html 我可以放置一个 html 文件,当您打开 example.com 时将使用该文件。 还有根文件夹,我在其中存放了节点模块、index.mjs、package.json 和 index.html。 我原以为我会从 root 启动 index.mjs,然后在同一文件位置读入 index.html,但网站仍然是空白的。我确定我在这里遗漏了一些东西。任何帮助将不胜感激!
编辑:
app.get('/',(req,res) => {
res.sendFile(__dirname + '/index.html');
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)