Google app engine 如何阻止Google应用程序引擎启动器记录整个html内容?
我使用以下代码来使用webapp2Google app engine 如何阻止Google应用程序引擎启动器记录整个html内容?,google-app-engine,Google App Engine,我使用以下代码来使用webapp2 import webapp2 from webapp2_extras import i18n, jinja2 class Test(webapp2.RequestHandler): @webapp2.cached_property def jinja2(self): # Returns a Jinja2 renderer cached in the app registry. return jinja2.get_
import webapp2
from webapp2_extras import i18n, jinja2
class Test(webapp2.RequestHandler):
@webapp2.cached_property
def jinja2(self):
# Returns a Jinja2 renderer cached in the app registry.
return jinja2.get_jinja2(app=self.app)
def render(self, _template, **context):
# Renders a template and writes the result to the response.
rv = self.jinja2.render_template(_template, **context)
self.response.write(rv)
def get(self):
self.render('index2.html')
app = webapp2.WSGIApplication([('/',Test)], debug=False)
app.run()
简单地说,我们只是让index2.html充满了1000test
如果您运行它,您会发现Google应用程序引擎启动程序日志窗口中充满了test
当你调试一个真正的网站时,这是相当可怕的
但是我发现如果index2.html只包含一些单词,比如10test
。测试将不会出现在日志窗口中
有解决方案吗?看起来您正在运行应用程序的两个独立实例
第一个通过开发服务器运行,第二个实际运行并输出到终端。您可以通过向应用程序添加日志输出看到这一点。您可以看到,当您访问站点时,日志会被写入两次
您可以通过删除该行来解决此问题:
app.run()
在应用程序引擎上运行时,这不是必需的。您的app.yaml
文件直接引用该应用程序:
handlers:
- url: .*
script: guestbook.app # Notice the .app here.