将Python代码与HTML集成的最佳方法 [英] Best way to integrate Python code with HTML

查看:269
本文介绍了将Python代码与HTML集成的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试整合Python和HTML。我在我的Apache服务器上安装了mod_python,我想知道是否有特定的方式来运行脚本,或者如果我应该(直接在HTML中)。

通过HTML使用Python的最佳方式是什么?

解决方案

最好的方法是设置一个使用Python的Web框架。一些不错的选择是 Django TurboGears 金字塔。尽管可以使用纯Python CGI或者作为ISAPI扩展,但是你并没有真正从这种方法中获益,而且一个web框架必定更加高效,易于理解和有用。



此外,Web框架带有一个理念,包含许多仔细的想法和最佳实践,您可以在工作时学习。


This is the first time I've tried to integrate Python and HTML. I have mod_python installed on my Apache server, and I'm wondering if there's a specific way I should run a script, or if I should (can I?) put the code directly in the HTML.

What are the best ways of using Python through HTML?

解决方案

The best way is to set up a web framework that uses Python. Some good choices are Django, TurboGears, and Pyramid. While it is possible to do pure Python CGI or as an ISAPI extension, you don't really gain much from that approach, and a web framework is bound to be more efficient, understandable, and helpful.

Furthermore, web frameworks come with a philosophy and contain a lot of careful thought and best practices that you can learn from while you're working.

这篇关于将Python代码与HTML集成的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆