2

we ara planning to make a program for raspberry pi 3. We figured out that maybe it would be better to write this program as a website with python.

If the button is a website element, and the website using python, can i control linux functions thru website on raspberry?

This is a user dashboard with several functions like media library, google maps integration, google places near and so on.

Ignity
  • 23
  • 3

2 Answers2

2

If the button is a website element, and the website using python, can i control linux functions thru website on raspberry?

Yes, basically you can do this with these python functions : os.system("someapp.sh") (launch a task),commands.getstatus("someapp.sh") (launch & read exit status code) or commands.getstatusoutput("someapp.sh") (launch and read both return code and result as a string)

You can also play with subprocess, reading and feeding application in real time with subprocess.Popen(["someapp.sh"], stdout=PIPE)

Technico.top
  • 1,426
  • 13
  • 20
1

The great thing about programming is that you can do pretty much whatever you want to do if you have the right level of knowledge. What you're talking about has two primary components.

  1. A webpage. This will probably be written in HTML/CSS with a little Javascript for asynchronous functionality.

  2. A python backend that accepts commands and then does things to your RPi. I would suggest you look into python's Flask API for this.

WARNING THERE BE DRAGONS HERE

You need to be very careful about running a webpage that includes system manipulation. Make sure you're familiar with the concept of injection attacks. Python is slightly safer in this regard than SQL, but be extremely wary of any input that comes from user space. Just because your website doesn't have the option, doesn't mean they can't access a public API directly.

Jacobm001
  • 11,904
  • 7
  • 47
  • 58