【发布时间】:2014-05-14 13:48:33
【问题描述】:
我有脚本,在CGIHTTPServer 下运行。
脚本包含:
$ cat cgi-bin/mysql.py
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """
<html>
<body>
<h2>Test</h2>
<button type="button">Get version</button>
</body>
</html>
"""
和函数(在其他脚本或这个):
def myver(host, user, pwd, cmd):
db = MySQLdb.connect(host, user, pwd)
cursor = db.cursor()
cursor.execute(cmd)
data = cursor.fetchone()
print "Database version : %s " % data
db.close()
myver('localhost', 'username', 'megapass', 'SELECT VERSION()')
我怎样才能将这个函数的结果放到同一个网页上?
HowTo 的链接将是完美的。或者一些例子。
【问题讨论】: