Google App Engine(GAE) wsgiref.handlers.CGIHandler Error

error using:

def main():
application = webapp.WSGIApplication(
[('/admin', MainHandler)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)

error message:

ERROR    2012-11-05 08:32:42,655 traceback.py:13]   File “C:\Python27\lib\wsgiref\handlers.py”, line 86, in run
ERROR    2012-11-05 08:32:42,655 traceback.py:13]     self.finish_response()
ERROR    2012-11-05 08:32:42,655 traceback.py:13]   File “C:\Python27\lib\wsgiref\handlers.py”, line 127, in finish_response
ERROR    2012-11-05 08:32:42,655 traceback.py:13]     self.write(data)
ERROR    2012-11-05 08:32:42,655 traceback.py:13]   File “C:\Python27\lib\wsgiref\handlers.py”, line 202, in write
ERROR    2012-11-05 08:32:42,655 traceback.py:13]     assert type(data) is StringType,”write() argument must be string”
ERROR    2012-11-05 08:32:42,655 traceback.py:13] AssertionError: write() argument must be string

Fix code:

def main():
application = webapp.WSGIApplication(
[('/admin', MainPage)],
debug=True)
run_wsgi_app(application)

########################################

same Error message for this code:

1. self.response.out.write(template.render(path, template_values))

2.

content = template.render(path, template_values)
self.response.out.write(content.encode(‘utf-8′))

此条目发表在Program分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>