How to execute Python scripts from HTML button
How to execute Python scripts from HTML button
My html page has a button and when I click that button I need to execute a python file. I don't need to show the python file content in browser, I only need to execute the python file by clicking the html button. When executing the python file, it will generate a json file which I need.
This is my code and it's opening the python file but not showing any output.
<html>
<body>
<h1> DEVELOPMENT </h1>
<form action="phpfile.php" method="post">
<input type="submit" name="someAction" value="GO" />
</form>
</body>
</html>
<?php
$result_last_line = system("python C:/xampp/htdocs/NEW/pythonfile/identifyrooms.py");
header('Location: view.html');
exit;
?>
When I run my python file using editor the output console is as below.
Can anyone find the error?.
Thanks
I found the solution. There was an error in my python file. I found the error using apache log file.
– john mathews
Sep 13 '18 at 7:35
Feel free to post how you found your solution below as an answer
– cricket_007
Sep 13 '18 at 7:36
The above code I mentioned is correct and has no issue. So I checked the error log file which is in C:xamppapachelogs folder. There I found the error saying, ImportError: No module named MySQLdb The syntax of the command is incorrect. So I removed that import statement since I didn't use it.
– john mathews
Sep 13 '18 at 8:27
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Well, you typically would write a Web Server in python to achieve a better result.
– cricket_007
Sep 13 '18 at 7:21