0

On my raspberry pi i have apache2 running. i have a very basic image displayed when you go to the site. What i want to be able to do is, when the image is clicked i want the following script to run.

import subprocess
subprocess.call('./milight_sources/milight 0 ON', shell=True) 

Now, i'm pretty sure django isn't the answer and neither is Flask. can you suggest the best way to do this? perhaps i don't even need to use a framework at all?

I'm pulling my hair out over this and am determinted to get it working. any suggestions will be great.

Many thanks!

3
  • A template system like jinja? jinja.pocoo.org Commented Feb 14, 2016 at 17:36
  • It's pretty easy to do using cgi-bin. Add the python file to your cgi-bin folder, make sure .py files are enabled for cgi scripts, chmod the python file to 755, then add a javascript redirect when someone clicks on the image. You can also add a redirect at the bottom of the python file to return to the webpage you were on. Commented Feb 14, 2016 at 17:45
  • Thank you so much, this is exactly what I am looking for. Something simple and I've just read through how the cgi-bin works and it's exactly what I need. thank you thank you thank you!! Commented Feb 15, 2016 at 10:01

1 Answer 1

1

Sounds like a small script that utilizes cgi should do the job

https://docs.python.org/2/library/cgi.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.