0

I was wondering if anyone knows a way to run python programs with HTML/JavaScript? I am strictly wanting to execute a python program by clicking a button from a simple webpage and my python code runs. I am not wanting to display my code on the site.

Using HTML I have tried:

<html>
<h1>Button</h1>
<p><a href="C:\user\Desktop\pythonprogram.py">Click Here</a></p>
</html>

This only takes me to the source code of my .py file. Is there a way to make this execute like an .exe file?

I have seen this method but not sure if it works: http://wiki.qt.io/Packaging_PySide_applications_on_Windows

Please let me know if this is doable. Maybe I need to use JavaScript?

ADD: I am using Python Version 3.6 and Spyder as IDE with XAMPP installed as well

Thank you!

alex_fields1
  • 71
  • 1
  • 2
  • 12
  • Possible duplicate of [How to run python script in webpage](https://stackoverflow.com/questions/7460938/how-to-run-python-script-in-webpage) – JoshG Jun 29 '18 at 17:34
  • Thank you however, I am not wanting to show my code I want to run a python program with just clicking a button on the webpage. – alex_fields1 Jun 29 '18 at 17:36
  • Right. The selected answer on that linked question explains how to do this. You will need a server properly configured to serve and run Python scripts to do this. – JoshG Jun 29 '18 at 17:40
  • If you're not going to install a local web server then you're asking how to run an executable from a web page. What operating system is this? It can be done on some of them and there are existing Stack Overflow questions showing how. For example in Windows you could set up a URI prefix similar to mailto: – Dave S Jun 29 '18 at 17:45
  • @DaveS I am running this on Windows 10. Could you reference the example you are talking about? I am new to programming so I am not sure what URI prefixes are. Also I have XAMPP installed so if that's an option I can do that? Thank you! – alex_fields1 Jun 29 '18 at 17:47
  • @AndroidNoobie My apologies, I believe I read through the question too fast. Thank you for the reference! – alex_fields1 Jun 29 '18 at 17:47
  • For XAMPP, see @AndroidNoobie 's link. A URI prefix is something like http:// but changed to (for example) pyscript:// . You need to set up a bunch of registry keys to get this to work, and probably write some kind of wrapper EXE. XAMPP is much simpler. – Dave S Jun 29 '18 at 17:49
  • @DaveS Thank you, I appreciate your help – alex_fields1 Jun 29 '18 at 17:52

0 Answers0