1
所以我在我的服务器上安装了python,并且使用带有apache的wsgi_module。我必须使用wsgi_module的“def application”吗?
尽我所有的Python程序都使用此格式:
def application(environ, start_response):
headers = []
headers.append(('Content-Type', 'text/plain'))
write = start_response('200 OK', headers)
input = environ['wsgi.input']
output = cStringIO.StringIO()
print >> output, "test"
output.write(input.read(int(environ.get('CONTENT_LENGTH', '0'))))
return [output.getvalue()]
反正是有设定,让我可以写Python脚本,只是有:
print "test"
好吧我想更重要的是我希望能够打印出类似于PHP刷新方法的东西。就像我希望能够打印,睡觉(1),打印。在这些wsgi标准下,这种事情是可能的吗? – Rawr 2012-08-10 10:58:14
@Rawr你在谈论的东西在WSGI标准中有很好的记载:http://www.python.org/dev/peps/pep-0333/#buffering-and-streaming。花点时间看看,所有问题都应该得到解答。 – 2012-08-10 11:00:47