Reputation: 119
I want to run python scripts on raspberry pi and control this process with my android phone. Now, I can run python scripts on rpi3 from my phone via ssh. I have 2 questions:
If a python script on the pi runs how could I stop running the script with my phone?
How can I send back a message to my phone that the script-running has ended?
Thanks
Upvotes: 1
Views: 602
Reputation: 3163
The easiest way would be to use Flask. Flask is a Python library that basically runs a website server for you. Then you can create a website with Flask in which you have some buttons or switches. You can add actions to buttons (they are basically HTML buttons). So if you want to for example run a python script or stop it, you can just set the button's action to that. I advise you to read documentation for more.
Now mind, that Flask is really lightweight, so if you plan to be extending your project significantly, you may want to consider using Nginx or Apache as a website back-end server, because they are more powerfull and Raspberry Pi can handle both easily (I am currently running Nginx on mine, was previously running Apache 2). In this case you might need to know a bit of JavaScript or PHP to be able to execute commands or if you don't mind learning, you can get yourself into Django, a pure-python front-end webserver which you combine with Nginx or Apache. I am running Nginx + Django for all dynamic-content sites I have/develop. There are lots of tutorials on YouTube snd documentation is among the best out there. Everything explained in great detail (some things aren't though, but great majority is) with lots of examples.
Upvotes: 3