Files
crm.twinpol.com/modules/EcmInvoiceOuts/test.php

17 lines
428 B
PHP
Raw Normal View History

2025-08-22 16:17:07 +02:00
<?php
// Runs the Python script, waits for completion, and returns its output.
2025-05-12 15:44:39 +00:00
2025-08-22 16:17:07 +02:00
$cmd = 'python3 /var/www/html/modules/EcmInvoiceOuts/ai/test.py';
$output = [];
$returnVar = 0;
exec($cmd . ' 2>&1', $output, $returnVar);
2025-05-12 15:44:39 +00:00
2025-08-22 16:17:07 +02:00
if ($returnVar !== 0) {
http_response_code(500);
echo "Error running Python script:\n" . implode("\n", $output);
exit;
}
2025-05-12 15:44:39 +00:00
2025-08-22 16:17:07 +02:00
// Expect a single line with the count
echo trim(implode("\n", $output));