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.
Output of python file in editor



Can anyone find the error?.

Thanks






Well, you typically would write a Web Server in python to achieve a better result.

– cricket_007
Sep 13 '18 at 7:21






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.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)