Currently I'm having some python files which connects to sqlite database for user inputs and then performs some calculations which sets the output of the program. I'm new to python web programming and I want to know what is the best method to use python on web?
Ex: I want to run my python files when the user clicks a button on the web page. Is it possible?
I started with Django. But it needs some time for the learning. And I also saw something called CgiScripts. Which option should I use? Please advice.
To run, open command prompt to the New folder directory, type python server.py to run the script, then go to browser type localhost:5000 , then you will see button. You can click and route to destination script file you created. Hope this helpful.
You can able to run a python file using html using php
write a PHP file as index.php:
<html> <head> <title>run my python files</title> <?PHP echo shell_exec("python test.py 'parameter1'"); ?> </head>
passing the parameter to python create a python as test.py:
import sys input=sys.argv[1] print(input)
print the parameter passed by PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With