我想要在终端中使用HTML格式化一个.py文件(在每次刷新页面时都会生成一个随机面部),该文件可以在浏览器中运行。我有chmod`ed它所以它应该工作,但每当我在浏览器中运行它,我得到一个内部服务错误。有人能帮我弄清楚它有什么不对吗?使用HTML格式化.py文件
#!/usr/bin/python
print "Content-Type: text/html\n"
print ""
<!DOCTYPE html>
<html>
<pre>
from random import choice
def facegenerator():
T = ""
hair = ["I I I I I","^^^^^"]
eyes = ["O O"," O O ",]
nose = [" O "," v "]
mouth = ["~~~~~","_____","-----"]
T += choice(hair)
T += "\n"
T += choice(eyes)
T += "\n"
T += choice(nose)
T += "\n"
T += choice(mouth)
T += "\n"
return T
print facegenerator()
</pre>
</html>
该代码在IDLE中工作,但我无法在网页上工作。预先感谢任何帮助!