I have a temperature sensor on my Raspberry Pi 2, I read the data with a python script. My question is how do I run that script on the Apache server (with a push of a button). Specifically how do I run a Python script through Apache server?
1 Answer
The answer is you use the CGI (Common Gateway Interface).
The precise details of how you would use CGI depends on the script you want to use on the Pi.
There is a pigpio CGI example for my pigpio library in these Python examples.
There is a somewhat simpler method not involving pigpio or Apache if you run your own Python server on the Raspberry Pi. There is example code called Easy as Pi Server at these Miscellanous examples. You'd need to look through the code example comments to see how it should be used.