简体   繁体   中英

Execute python script from within HTML

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!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM