[英]Execute python script from within HTML
On my raspberry pi i have apache2 running. 在我的树莓派上,我正在运行apache2。 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. 现在,我很确定django不是答案,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 听起来像一个利用cgi的小脚本可以完成这项工作
https://docs.python.org/2/library/cgi.html https://docs.python.org/2/library/cgi.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.