Update app.js

This commit is contained in:
甬哥侃侃侃ygkkk
2025-02-26 08:50:29 +08:00
committed by GitHub
parent 1901d0e2a9
commit 4b19de11fb
+16 -2
View File
@@ -37,17 +37,31 @@ app.get("/re", (req, res) => {
});
app.get("/rp", (req, res) => {
const changeportCommands = "cd ~ && bash webport.sh";
exec(changeportCommands, (err, stdout, stderr) => {
const changeportCommands = "cd ~ && env && bash webport.sh"; // 打印环境变量,帮助调试
exec(changeportCommands, { maxBuffer: 1024 * 1024 * 10 }, (err, stdout, stderr) => {
// 打印标准输出和错误输出
console.log('stdout:', stdout);
console.error('stderr:', stderr);
// 错误处理
if (err) {
console.error('Execution error:', err);
return res.status(500).send(`错误:${stderr || stdout}`);
}
// 如果有标准错误,返回错误信息
if (stderr) {
console.error('stderr output:', stderr);
return res.status(500).send(`stderr: ${stderr}`);
}
// 返回正常的输出
res.type('text').send(stdout);
});
});
app.get("/list/key", (req, res) => {
const listCommands = `
USERNAME=$(whoami | tr '[:upper:]' '[:lower:]')