I have a very simple web page which I'm using in order to rotate a stepper motor on Raspberry Pi. My html file is this:
function ccw()
{
document.location="cgi-bin/rotate_45_ccw.py";
}
function cw()
{
document.location="cgi-bin/rotate_45_cw.py";
}
Raspberry Pi GPIO
Rotate CCW
Rotate CW
What I want to do is after either of the scripts is executed, for the page to be refreshed (so that the user can click again on either button). The dumb way I guess, is for the Python scripts to output the above html code. Is there a smarter/easier way?
Thanks!
解决方案
After a LOT of searching around I finally got it right! So, in order to be redirected to the home page, I have to add the following print statements at the end of my python3 script:
print ("Content-type: text/html\n\n")
print ("
\n")print ("")
print ("")