How to run a file on raspberry pi 3 [n00b]


I started with node-red yesterday. What would be the best way to have a button (in html I guess) to fire a node that runs a python file on the raspberry pi 3?

At present I have a tkinter window GUI program on the rpi3 with 4 buttons that serve the purpose of running 4 different python files on the rpi3, but Id like to replace that GUI with a html based solution?



Several ways, of course. If you already have the HTML page, just modify the buttons to point to a node-red http endpoint (e.g. http://nodered_host:1880/button/1) passing the button number on the url path.

Then if you create a flow that starts with an http in node, set it's path to be /button/:id -- then every time one of the buttons is pressed, your flow can access the button id through the property. Based on that you can switch to the correct python script node.

Just keep in mind that every http input flow needs to end with an http response node, set to return an appropriate status (200 ok, or 204 no content, even 500 error). Also, make sure you don't wipe out the msg.req and msg.res properties in your flow, or else the response will never get back to the client.



Ok I managed to create the http-in node which passes values to a function that stores them in variables and uses the msg object to pass them as msg.req.query.var1 and var2 (and adds them) and sends them to the html response node as html text. And I can see the values at:


and I get 9. Perfect! Now is there a way to build a main page at localhost:1880 where I can build my html form to have the user input those values and have them parsed?



take a look at this