【发布时间】:2009-08-18 17:44:58
【问题描述】:
我是 Python 和 CGI 的新手,所以这可能是微不足道的。但我希望 Python 在访问者加载页面时生成一个 HTML 块。
<html>
<body>
<!-- Beautiful website with great content -->
<!-- Suddenly... -->
<h1> Here's Some Python Output </h1>
<!-- RUN PYTHON SCRIPT, display output -->
</body>
</html>
使用 Python 脚本,为简单起见,如下所示:
#!/usr/bin/python
print "Content-type: text/html"
print
print "<p>Hello world!</p>"
我能找到的大多数资源都展示了如何使用 Python 脚本制作整个网页。你能在页面中间调用一个 Python 脚本来生成一个 HTML sn-p 吗?
【问题讨论】:
-
那些想在内容琐碎的丑陋网站上运行 python 脚本的人怎么办?
-
你怎么能运行python脚本“mod-page”?那有什么意思?您是否尝试将 CGI 编写为一个大的 shell 脚本,并在 shell 脚本上使用小块 Python?为什么要这么复杂?