[英]Google app engine Python issue
我使用html5和php开发了应用程序。 由于谷歌app引擎尚未完全支持php,我想将我的PHP代码更改为python,因为我有8行php代码。 问题是,我是python的总菜鸟。 我习惯使用index.html运行良好的php,但是当我尝试使用python运行index.html时,我得到了空白页面。 有人可以解释如何在谷歌应用引擎上使用python运行html5文档。 这是我试过的:
html = """
here goes my site
""";
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.render(html);
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
我检查了GAE python启动教程。 也许你的代码
self.render(html);
应该:
self.response.write("Hello world!");
我不认为webapp2.RequestHandler类具有渲染功能,因为我在GAE的云端游戏中尝试了你的代码,它引发了一个错误:
AttributeError:'MainHandler'对象没有属性'render'
如果你想渲染一个模板,它应该像这样使用:
......
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render(template_values))
文档在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.