Files
sing-box-yg/app.js
T
2025-01-27 09:09:31 +08:00

32 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
require('dotenv').config();
const express = require("express");
const { exec } = require('child_process');
const app = express();
app.use(express.json());
app.get("/up", function (req, res) {
const commandToRun = "cd ~ && bash serv00keep.sh";
exec(commandToRun, function (err, stdout, stderr) {
if (err) {
console.log("命令执行错误: " + err);
res.status(500).send("服务器错误");
return;
}
if (stderr) {
console.log("命令执行标准错误输出: " + stderr);
}
console.log("命令执行成功:\n" + stdout);
});
res.type("html").send("<pre>Serv00网页保活启动:Serv00!一柱擎天!UPUPUP</pre>");
});
app.use((req, res, next) => {
if (req.path === '/up') {
return next();
}
res.status(404).send('把浏览器地址改为:http://你的serv00用户名.你的serv00用户名.serv00.net/up 这样才能启动Serv00网页保活');
});
app.listen(3000, () => {
console.log("服务器已启动,监听端口 3000");
});