代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Puter 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const express = require("express");
const { generateDevHtml, build } = require("./utils.js");
const { argv } = require('node:process');
const chalk = require('chalk');
const app = express();
let port = 4000; // Starting port
const maxAttempts = 10; // Maximum number of ports to try
const env = argv[2] ?? "dev";
const startServer = (attempt) => {
if (attempt > maxAttempts) {
console.error(chalk.red(`ERROR: Unable to find an available port after ${maxAttempts} attempts.`));
return;
}
app.listen(port, () => {
console.log("\n-----------------------------------------------------------\n");
console.log(`Puter is now live at: `, chalk.underline.blue(`http://localhost:${port}`));
console.log("\n-----------------------------------------------------------\n");
}).on('error', (err) => {
if (err.code === 'EADDRINUSE') { // Check if the error is because the port is already in use
console.error(chalk.red(`ERROR: Port ${port} is already in use. Trying next port...`));
port++; // Increment the port number
startServer(attempt + 1); // Try the next port
}
});
};
// Start the server with the first attempt
startServer(1);
// build the GUI
build();
app.get(["/", "/app/*", "/action/*"], (req, res) => {
res.send(generateDevHtml({
env: env,
api_origin: "https://api.puter.com",
title: "Puter",
max_item_name_length: 150,
require_email_verification_to_publish_website: false,
short_description: `Puter is a privacy-first personal cloud that houses all your files, apps, and games in one private and secure place, accessible from anywhere at any time.`,
}));
})
app.use(express.static('./'));
if(env === "prod"){
// make sure to serve the ./dist/ folder maps to the root of the website
app.use(express.static('./dist/'));
}
if(env === "dev"){
app.use(express.static('./src/'));
}
module.exports = app;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。