|
@@ -180,5 +180,31 @@ public class BaseFarmController {
|
|
|
return "成功";
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/testPython")
|
|
|
+ public String testPython() throws InterruptedException {
|
|
|
+
|
|
|
+ try {
|
|
|
+ String[] my_args =new String[] {"python3","detect.py"};
|
|
|
+ Process proc = Runtime.getRuntime().exec(my_args);//执行脚本
|
|
|
+ System.out.println("执行脚本");
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
|
|
+ String line = null;
|
|
|
+ while((line = reader.readLine()) != null){
|
|
|
+ System.out.println("python执行结果"+line);
|
|
|
+ }
|
|
|
+
|
|
|
+ reader.close();
|
|
|
+ int exitCode = proc.waitFor();
|
|
|
+ System.out.println("Python script exited with code " + exitCode);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "成功";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|