Регулярное выражение
This commit is contained in:
21
server.js
21
server.js
@@ -37,6 +37,27 @@ let serverReady = false;
|
||||
let adminRouter = null;
|
||||
let upload = null;
|
||||
|
||||
let cachedHtml = null;
|
||||
app.get('/', (req, res) => {
|
||||
if (cachedHtml) {
|
||||
// Заменяем плейсхолдеры в закешированном HTML (на случай, если переменные окружения изменились – но обычно они не меняются во время работы)
|
||||
let modifiedHtml = cachedHtml
|
||||
.replace(/{{APP_NAME}}/g, process.env.APP_NAME)
|
||||
.replace(/{{APP_VERSION}}/g, process.env.APP_VERSION)
|
||||
.replace(/{{SCHOOL_NAME}}/g, process.env.SCHOOL_NAME);
|
||||
return res.send(modifiedHtml);
|
||||
}
|
||||
|
||||
const filePath = path.join(__dirname, 'public', 'index.html');
|
||||
fs.readFile(filePath, 'utf8', (err, html) => {
|
||||
if (err) {
|
||||
return res.status(500).send('Ошибка');
|
||||
}
|
||||
cachedHtml = html;
|
||||
// ... отправка
|
||||
});
|
||||
});
|
||||
|
||||
// Инициализируем multer сразу с настройками по умолчанию
|
||||
const uploadsDir = path.join(__dirname, 'data', 'uploads');
|
||||
const createDirIfNotExists = (dirPath) => {
|
||||
|
||||
Reference in New Issue
Block a user