-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunPython.php
More file actions
37 lines (26 loc) · 1.08 KB
/
runPython.php
File metadata and controls
37 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
//system('C:\Users\pranay\AppData\Local\Programs\Python\Python36-32\python hello.py', $retval);
//echo $retval;
function generateReport($filePath) {
echo $filePath."=================";
}
function tp($fileDir,$fileName,$options) {
$pythonPath = 'C:\Users\pc1\AppData\Local\Programs\Python\Python36-32\python ';
$pythonMainFile = 'C:\xampp\htdocs\www\WebPage\BTechProject\main.py';
$fileNameWithPath = ' C:\xampp\htdocs\www\WebPage\\'.$fileDir.' '.$options;
echo $pythonPath.$pythonMainFile.$fileNameWithPath;
//$filePath = ' C:\xampp\htdocs\www\WebPage\BTechProject'.$fileName.' 2';
//$filePath2 = ' C:\Users\pc1\Desktop\BTechProject(1)\main.py'.$fileName.' 2';
$res = exec($pythonPath.$pythonMainFile.$fileNameWithPath,$output,$return);
//echo $pythonPath.$filePath;
if($return === 0) {
// exec is successful only if the $return_var was set to 0. !== means equal and identical, that is it is an integer and it also is zero.
foreach($output as $value){
echo $value . "<br>";
}
}
else{
echo "UnSuccessfully";
}
}
?>