|
@@ -160,16 +160,20 @@ function init() {
|
|
|
const logPath = "./db/" + port + ".html";
|
|
|
const latestFile = path.resolve(logPath);
|
|
|
if (!fs.existsSync(latestFile)) {
|
|
|
- return res.status(404).send('没有找到文件。');
|
|
|
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
|
+ res.end('Not Found');
|
|
|
}
|
|
|
|
|
|
- // 设置下载响应
|
|
|
- res.download(latestFile, err => {
|
|
|
+ // 读取HTML文件
|
|
|
+ fs.readFile(latestFile, (err, content) => {
|
|
|
if (err) {
|
|
|
- res.status(500).send('下载失败, 异常信息:', err);
|
|
|
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
|
+ res.end('Internal Server Error');
|
|
|
+ } else {
|
|
|
+ res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
|
+ res.end(content);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
})
|
|
|
|
|
|
// 新策略-返回机器人状态
|