How to run python script in HTML?

匿名 (未验证) 提交于 2019-12-03 10:09:14

问题:

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.

回答1:

It probably would depend on what you want to do. I personally use CGI and it might be simpler if your inputs from the web page are simple, and it takes less time to learn. Here are some resources for it:

However you may still have to do some configuring to allow it to run the program instead of displaying it.

Here's a tutorial on that: http://httpd.apache.org/docs/current/howto/cgi.html



回答2:

If your web server is apache you can use the http://modpython.org/ module in order to run your python CGI scripts.

For nginx you can use http://modwsgi.readthedocs.io/en/develop/



回答3:

You can't run python directly

You may use this

http://karrigell.sourceforge.net/en/pythoninsidehtml.html

Or for inside php this

http://www.skulpt.org/


转载请标明出处:How to run python script in HTML?
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!