test python execute

This commit is contained in:
Michał Zieliński
2025-08-22 16:17:07 +02:00
parent d1ff1fa0ac
commit e2fddb327c
2 changed files with 50 additions and 15 deletions

28
modules/EcmInvoiceOuts/test.php Executable file → Normal file
View File

@@ -1,18 +1,16 @@
<?php
<?php
// Runs the Python script, waits for completion, and returns its output.
$cmd = 'python3 /var/www/html/modules/EcmInvoiceOuts/ai/test.py';
$output = [];
$returnVar = 0;
exec($cmd . ' 2>&1', $output, $returnVar);
if ($returnVar !== 0) {
http_response_code(500);
echo "Error running Python script:\n" . implode("\n", $output);
exit;
}
$url='http://damznac.pl/login'; // Specify your url
$data= array('username'=>'lol','api_key'=>'val'); // Add parameters in key value
$ch = curl_init(); // Initialize cURL
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return= curl_exec($ch);
var_dump($return);
curl_close($ch);
?>
// Expect a single line with the count
echo trim(implode("\n", $output));