@Hector said in Как обновлять скрипт на сервере?:
БАС приходится закрывать. потом копировать новый файл и потом заново открывать...........
Достаточно сохранить проект перед компиляцией
const Tesseract = require('tesseract.js');
// URL of the image to process
const imageUrl = 'https://i.pinimg.com/originals/43/57/06/435706ac8601df85a4312ea95e4f7401.jpg';
// Array to store log messages
const logs = [];
// Function to add a log message (finishes immediately)
function addLog(message) {
logs.push(message);
}
// Function to display all logs (finishes immediately)
function displayLogs() {
logs.forEach(log => console.log(log));
}
// Function to handle the OCR result (called asynchronously)
function handleResult(result) {
addLog('OCR Process Completed.');
addLog('Extracted Text: ' + result.data.text);
displayLogs(); // Display all logs at the end
}
// Function to perform OCR (asynchronous operation)
function performOCR(url) {
addLog('Starting OCR process.');
Tesseract.recognize(
url,
'eng',
{ logger: m => addLog(m.status + ' ' + Math.round(m.progress * 100) + '%') }
)
.then(handleResult)
.catch(error => {
addLog('An error occurred during OCR processing.');
addLog(error.toString());
displayLogs(); // Display all logs if an error occurs
});
}
// Start OCR process (initial call finishes immediately, but OCR is async)
performOCR(imageUrl);
const Tesseract = require('tesseract.js');
// URL of the image to process
const imageUrl = [[FILE_JPG]];
// Array to store log messages
const logs = [];
// Function to add a log message
function addLog(message) {
logs.push(message);
}
// Function to display all logs
function displayLogs() {
logs.forEach(log => console.log(log));
}
await (new Promise((resolve, reject) => {
// Function to perform OCR (asynchronous operation)
async function performOCR(url) {
addLog('Starting OCR process.');
try {
const result = await Tesseract.recognize(url, 'eng', {
logger: m => addLog(m.status + ' ' + Math.round(m.progress * 100) + '%')
});
// Handle OCR result
addLog('OCR Process Completed.');
addLog('Extracted Text: ' + result.data.text);
} catch (error) {
// Handle OCR error
addLog('An error occurred during OCR processing.');
addLog(error.toString());
}
resolve()
displayLogs(); // Display all logs at the end
}
// Call performOCR function asynchronously
performOCR(imageUrl);
}));