I'm trying to make my raspberry PI host a website for control of a system on my house but can't run server side Python
I've tried this in Javascript:
import { exec } from 'child_process';
exec("sudo python /home/pi/Light.py");
It's supposed to run Light.py server side because it contains GPIO instructions for the pi but the PI just sits there doing nothing
-
Can this answer help you? stackoverflow.com/questions/23450534/…Sergey Kirienko– Sergey Kirienko2019年04月15日 13:57:48 +00:00Commented Apr 15, 2019 at 13:57
1 Answer 1
Javascript's exec() is not for running anything server side, Python or otherwise.
Probably the easiest way to achieve what you're looking for would be to use a simple Python web framework, such as Flask. You could expose a simple HTTP endpoint doing whatever you need doing, and hit that from Javascript.
4 Comments
child_process looks like a node thing, which would also run server side. How's it being triggered? What happens if you SSH onto your Pi and run sudo python /home/pi/Light.py?sudo python /home/pi/Light.py?Explore related questions
See similar questions with these tags.