I made a Webserver using my Laptop and a few PHP-HTML-Javascript programms. Right now i am able to connect to these pages and everything works just fine. My problem is that i want to run a Python script on a RaspberryPi (using GPIOs to control neopixel LEDs) when a certain event occurs on the webpage. I am already succesfully "noticing" the event and i am able to start alerts if it happens.
My Question is: What code can i use in the Javascript on the webpage that starts the Python script on the RaspberryPi? Where does the Python script need to be saved? On the Pi or on the server?
The Python script is also working if i execute it from the terminal and it doesnt need any input data nor does it create output data, it should just controll the GPIOs
My RaspberryPi is not the Webserver, it is only connecting to it via browser.
Update: Got it to work thanks to the help in the answer, but now I am facing the next issue. I use an AJAX request to start my Python script controlling the LEDs, the routine takes 15 seconds until it is done. I want to be able to stop the LED-routine by pressing a button that is on the same webpage. I already tried
abort()
but it doesn't work in this case(or at least not how I am using it).
I also tried making a second webpage from the server on the Raspberry Pi and then access it with another AJAX request. The second page starts a script that turns off the LEDs. Currently I am not able to access the second page until the first one is done with the routine.