Calling A Python Script From A Webpage
Solution 1:
If it is a "fairly complex program" you may want to use a small framework that takes care of grouping the parts in a "standard", i.e. supported and documented, manner. I would look into lightweight Python Web frameworks as Flask and WebApp2. Lightweight in terms of both performance and learning curve.
Here you get a full overview of Python web frameworks.
Solution 2:
Solution 3:
Here is how it works:
user requestes a web page (a URL like http://127.0.0.1/start.html)
you have to serve the page to the user (either via a standalone webserver like apache or via some python lib like http.server, BaseHTTPServer, flask, cherrypy, ...)
user fills some values in some html form on your page (learn about html forms) when he hits submit another url is requested like http://127.0.0.1/myfunction.py?foo=1&bar=2
you have to handle the request to that url and extract the parameters from the url, for example via cgi, mod_py and apache or python frameworks like flask, cherrypy, etc.. and than you would execute your code using the parameters and generate a resulting html page and serve it via those tools
If you want to keep it really simple, learn howto use flask and html forms.
Post a Comment for "Calling A Python Script From A Webpage"