Is there a way to run python script for html webpage? it's very important. i have a python script works fine in my raspberry Pi but i want to work with my home page,
how can i do that?
Is there a way to run python script for html webpage? it's very important. i have a python script works fine in my raspberry Pi but i want to work with my home page,
how can i do that?
Please i want to know what's wrong in this html code to execute my python script via internet.
<html>
<head>
<?php
if (isset($_POST['LightON']))
{
exec("sudo python /var/www/lighton.py");
}
if (isset($_POST['LightOFF']))
{
exec("sudo python /var/www/lightoff.py");
}
?>
<form method="post">
<button class="btn" name="LightON">Light ON</button>
<button class="btn" name="LightOFF">Light OFF</button><br><br>
<br><br><br><br>
</form>
</html>
<?php
if (isset($_POST['LightON']))
{
exec("sudo python /var/www/lighton.py");
}
if (isset($_POST['LightOFF']))
{
exec("sudo python /var/www/lightoff.py");
}
?>
This has several issues:
If you want a simpler way to control the light take a look at REST API in http://lmgtfy.com/?q=raspberry+pi+rest+server