<bdo id='xVwZF'></bdo><ul id='xVwZF'></ul>
    <i id='xVwZF'><tr id='xVwZF'><dt id='xVwZF'><q id='xVwZF'><span id='xVwZF'><b id='xVwZF'><form id='xVwZF'><ins id='xVwZF'></ins><ul id='xVwZF'></ul><sub id='xVwZF'></sub></form><legend id='xVwZF'></legend><bdo id='xVwZF'><pre id='xVwZF'><center id='xVwZF'></center></pre></bdo></b><th id='xVwZF'></th></span></q></dt></tr></i><div id='xVwZF'><tfoot id='xVwZF'></tfoot><dl id='xVwZF'><fieldset id='xVwZF'></fieldset></dl></div>

      <legend id='xVwZF'><style id='xVwZF'><dir id='xVwZF'><q id='xVwZF'></q></dir></style></legend>

    1. <small id='xVwZF'></small><noframes id='xVwZF'>

      1. <tfoot id='xVwZF'></tfoot>
      2. 在 app.yaml 中定义路由与在 AppEngine 中的 WSGIAppli

        时间:2023-09-12
          <bdo id='FZwpw'></bdo><ul id='FZwpw'></ul>
          • <small id='FZwpw'></small><noframes id='FZwpw'>

              <i id='FZwpw'><tr id='FZwpw'><dt id='FZwpw'><q id='FZwpw'><span id='FZwpw'><b id='FZwpw'><form id='FZwpw'><ins id='FZwpw'></ins><ul id='FZwpw'></ul><sub id='FZwpw'></sub></form><legend id='FZwpw'></legend><bdo id='FZwpw'><pre id='FZwpw'><center id='FZwpw'></center></pre></bdo></b><th id='FZwpw'></th></span></q></dt></tr></i><div id='FZwpw'><tfoot id='FZwpw'></tfoot><dl id='FZwpw'><fieldset id='FZwpw'></fieldset></dl></div>

                    <tbody id='FZwpw'></tbody>
                  <legend id='FZwpw'><style id='FZwpw'><dir id='FZwpw'><q id='FZwpw'></q></dir></style></legend><tfoot id='FZwpw'></tfoot>
                  本文介绍了在 app.yaml 中定义路由与在 AppEngine 中的 WSGIApplication 中定义一个大型映射相比,是否有性能提升?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这涉及在 app.yaml 中使用一个网关"路由,然后在 WSGIApplication 中选择 RequestHandler.

                  This involves using one "gateway" route in app.yaml and then choosing the RequestHandler in the WSGIApplication.

                  - url: /.*
                    script: main.py
                  

                  main.py

                  from google.appengine.ext import webapp
                  
                  class Page1(webapp.RequestHandler):
                      def get(self):
                          self.response.out.write("Page 1")
                  
                  class Page2(webapp.RequestHandler):
                      def get(self):
                          self.response.out.write("Page 2")
                  
                  application = webapp.WSGIApplication([
                      ('/page1/', Page1),
                      ('/page2/', Page2),
                  ], debug=True)
                  
                  def main():
                      wsgiref.handlers.CGIHandler().run(application)
                  
                  if __name__ == '__main__':
                      main()
                  

                  <小时>

                  场景 2:

                  这涉及在 app.yaml 中定义两个路由,然后为每个路由定义两个单独的脚本(page1.pypage2.py).


                  Scenario 2:

                  This involves defining two routes in app.yaml and then two separate scripts for each (page1.py and page2.py).

                  - url: /page1/
                    script: page1.py
                  - url: /page2/
                    script: page2.py
                  

                  page1.py

                  from google.appengine.ext import webapp
                  
                  class Page1(webapp.RequestHandler):
                      def get(self):
                          self.response.out.write("Page 1")
                  
                  application = webapp.WSGIApplication([
                      ('/page1/', Page1),
                  ], debug=True)
                  
                  def main():
                      wsgiref.handlers.CGIHandler().run(application)
                  
                  if __name__ == '__main__':
                      main()
                  

                  page2.py

                  from google.appengine.ext import webapp
                  
                  class Page2(webapp.RequestHandler):
                      def get(self):
                          self.response.out.write("Page 2")
                  
                  application = webapp.WSGIApplication([
                      ('/page2/', Page2),
                  ], debug=True)
                  
                  def main():
                      wsgiref.handlers.CGIHandler().run(application)
                  
                  if __name__ == '__main__':
                      main()
                  

                  <小时>

                  问题

                  每种模式的优缺点是什么?一个比另一个快得多吗?


                  Question

                  What are the benefits and drawbacks of each pattern? Is one much faster than the other?

                  推荐答案

                  唯一的性能影响与模块的加载有关:模块在第一次使用时加载到实例上,拆分事物需要更少的模块加载到在新实例上提供页面.

                  The only performance implication relates to the loading of modules: Modules are loaded on an instance when they're first used, and splitting things up requires fewer module loads to serve a page on a new instance.

                  不过,这非常简单,因为您可以轻松地让处理程序脚本按需动态加载所需的模块 - 这就是许多常见框架已经做的事情.

                  This is pretty minimal, though, as you can just as easily have the handler script dynamically load the needed module on-demand - and that's what many common frameworks already do.

                  一般来说,app.yaml 路由是为不同组件或应用程序之间的路由而设计的.例如,remote_api 和 deferred 都有自己的处理程序.因此,为您的应用定义一个处理其他所有内容的处理程序是完全合理的.

                  In general, app.yaml routing is designed for routing between distinct components or applications. For example, remote_api and deferred both have their own handlers. It's perfectly reasonable, therefore, to have a single handler defined for your app that handles everything else.

                  这篇关于在 app.yaml 中定义路由与在 AppEngine 中的 WSGIApplication 中定义一个大型映射相比,是否有性能提升?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:通过 ruamel.yaml 转储时如何在 yaml 文件中保留空值 下一篇:将 json 转储到 yaml

                  相关文章

                  最新文章

                  <legend id='SyOE8'><style id='SyOE8'><dir id='SyOE8'><q id='SyOE8'></q></dir></style></legend>

                    1. <tfoot id='SyOE8'></tfoot>
                      <i id='SyOE8'><tr id='SyOE8'><dt id='SyOE8'><q id='SyOE8'><span id='SyOE8'><b id='SyOE8'><form id='SyOE8'><ins id='SyOE8'></ins><ul id='SyOE8'></ul><sub id='SyOE8'></sub></form><legend id='SyOE8'></legend><bdo id='SyOE8'><pre id='SyOE8'><center id='SyOE8'></center></pre></bdo></b><th id='SyOE8'></th></span></q></dt></tr></i><div id='SyOE8'><tfoot id='SyOE8'></tfoot><dl id='SyOE8'><fieldset id='SyOE8'></fieldset></dl></div>

                      • <bdo id='SyOE8'></bdo><ul id='SyOE8'></ul>
                    2. <small id='SyOE8'></small><noframes id='SyOE8'>