test python execute
This commit is contained in:
28
modules/EcmInvoiceOuts/test.php
Executable file → Normal file
28
modules/EcmInvoiceOuts/test.php
Executable file → Normal 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));
|
||||
|
||||
Reference in New Issue
Block a user