简体   繁体   English

是否可以通过在 Raspberry Pi 上运行的 flutter 应用程序运行 python 脚本?

[英]Is it possible to run python scripts trough a flutter app running on Raspberry Pi?

I am working on an automation app for Raspberry that requires a few python scripts to work.我正在为 Raspberry 开发一个自动化应用程序,它需要一些 python 脚本才能工作。 I made the front end in flutter.我在 flutter 中制作了前端。 Is it possible to run these python scripts through a flutter app running on Raspberry Pi when a button in that app is pressed?当按下该应用程序中的按钮时,是否可以通过在 Raspberry Pi 上运行的 flutter 应用程序运行这些 python 脚本? (for example turning a stepper motor, sending current through a GPIO pin for a few seconds) It should work offline, and I would prefer if these scripts were saved as an external.py file. (例如转动步进电机,通过 GPIO 引脚发送电流几秒钟)它应该可以离线工作,我希望这些脚本保存为 external.py 文件。

To run the app on raspberry, I was planning on using https://github.com/ardera/flutter-pi If there is a better variant to do that, please tell me so.为了在 raspberry 上运行应用程序,我计划使用https://github.com/ardera/flutter-pi如果有更好的变体,请告诉我。

With process_run package you can call scripts like in the command line.使用process_run package 您可以像在命令行中一样调用脚本。 From the way I understand your problem you could prepare the required python scripts, store them and call them with process_run whenever you need them.根据我理解您的问题的方式,您可以准备所需的 python 脚本,存储它们并在需要时使用 process_run 调用它们。

This is roughly equivalent to the python module called subprocess .这大致相当于称为subprocess的 python 模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM