当前位置: 首页>>代码示例>>Python>>正文


Python webapp2.Route方法代码示例

本文整理汇总了Python中webapp2.Route方法的典型用法代码示例。如果您正苦于以下问题:Python webapp2.Route方法的具体用法?Python webapp2.Route怎么用?Python webapp2.Route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webapp2的用法示例。


在下文中一共展示了webapp2.Route方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_routes():
  routes = [
      # AppEngine-specific urls:
      webapp2.Route(r'/_ah/mail/<to:.+>', EmailHandler),
      webapp2.Route(r'/_ah/warmup', WarmupHandler),
  ]
  if not utils.should_disable_ui_routes():
    routes.extend([
      # Administrative urls.
      webapp2.Route(r'/restricted/config', RestrictedConfigHandler),
      webapp2.Route(r'/restricted/purge', RestrictedPurgeHandler),

      # User web pages.
      webapp2.Route(r'/browse', BrowseHandler),
      webapp2.Route(r'/content', ContentHandler),
      webapp2.Route(r'/', RootHandler),
      webapp2.Route(r'/newui', UIHandler),
    ])
  routes.extend(handlers_endpoints_v1.get_routes())
  return routes 
开发者ID:luci,项目名称:luci-py,代码行数:22,代码来源:handlers_frontend.py

示例2: get_ui_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_ui_routes():
  """Returns a list of routes with auth UI handlers."""
  routes = []
  if not utils.should_disable_ui_routes():
    # Routes for registered navbar tabs.
    for cls in _ui_navbar_tabs:
      routes.extend(cls.get_webapp2_routes())
    # Routes for everything else.
    routes.extend([
      webapp2.Route(r'/auth', MainHandler),
      webapp2.Route(r'/auth/bootstrap', BootstrapHandler, name='bootstrap'),
      webapp2.Route(r'/auth/bootstrap/oauth', BootstrapOAuthHandler),
      webapp2.Route(r'/auth/link', LinkToPrimaryHandler),
      webapp2.Route(r'/auth/listing', GroupListingHandler),
    ])
  return routes 
开发者ID:luci,项目名称:luci-py,代码行数:18,代码来源:ui.py

示例3: explorer_proxy_route

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def explorer_proxy_route(base_path):
  """Returns a route to a handler which serves an API explorer proxy.

  Args:
    base_path: The base path under which all service paths exist.

  Returns:
    A webapp2.Route.
  """
  class ProxyHandler(webapp2.RequestHandler):
    """Returns a proxy capable of handling requests from API explorer."""

    def get(self):
      self.response.write(template.render(
          'adapter/proxy.html', params={'base_path': base_path}))

  template.bootstrap({
      'adapter': os.path.join(THIS_DIR, 'templates'),
  })
  return webapp2.Route('%s/static/proxy.html' % base_path, ProxyHandler) 
开发者ID:luci,项目名称:luci-py,代码行数:22,代码来源:adapter.py

示例4: explorer_redirect_route

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def explorer_redirect_route(base_path):
  """Returns a route to a handler which redirects to the API explorer.

  Args:
    base_path: The base path under which all service paths exist.

  Returns:
    A webapp2.Route.
  """
  class RedirectHandler(webapp2.RequestHandler):
    """Returns a handler redirecting to the API explorer."""

    def get(self):
      host = self.request.headers['Host']
      self.redirect('https://apis-explorer.appspot.com/apis-explorer'
                    '/?base=https://%s%s' % (host, base_path))

  return webapp2.Route('%s/explorer' % base_path, RedirectHandler) 
开发者ID:luci,项目名称:luci-py,代码行数:20,代码来源:adapter.py

示例5: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def __init__(self, dispatch, configuration):
    """Initializer for AdminApplication.

    Args:
      dispatch: A dispatcher.Dispatcher instance used to route requests and
          provide state about running servers.
      configuration: An application_configuration.ApplicationConfiguration
          instance containing the configuration for the application.
    """
    super(AdminApplication, self).__init__(
        [('/datastore', datastore_viewer.DatastoreRequestHandler),
         ('/datastore/edit/(.*)', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore/edit', datastore_viewer.DatastoreEditRequestHandler),
         ('/datastore-indexes',
          datastore_indexes_viewer.DatastoreIndexesViewer),
         ('/datastore-stats', datastore_stats_handler.DatastoreStatsHandler),
         ('/console', console.ConsoleRequestHandler),
         ('/console/restart/(.+)', console.ConsoleRequestHandler.restart),
         ('/memcache', memcache_viewer.MemcacheViewerRequestHandler),
         ('/blobstore', blobstore_viewer.BlobstoreRequestHandler),
         ('/blobstore/blob/(.+)', blobstore_viewer.BlobRequestHandler),
         ('/taskqueue', taskqueue_queues_handler.TaskQueueQueuesHandler),
         ('/taskqueue/queue/(.+)',
          taskqueue_tasks_handler.TaskQueueTasksHandler),
         ('/cron', cron_handler.CronHandler),
         ('/xmpp', xmpp_request_handler.XmppRequestHandler),
         ('/mail', mail_request_handler.MailRequestHandler),
         ('/quit', quit_handler.QuitHandler),
         ('/search', search_handler.SearchIndexesListHandler),
         ('/search/document', search_handler.SearchDocumentHandler),
         ('/search/index', search_handler.SearchIndexHandler),
         ('/assets/(.+)', static_file_handler.StaticFileHandler),
         ('/instances', servers_handler.ServersHandler),
         webapp2.Route('/',
                       webapp2.RedirectHandler,
                       defaults={'_uri': '/instances'})],
        debug=True)
    self.dispatcher = dispatch
    self.configuration = configuration 
开发者ID:elsigh,项目名称:browserscope,代码行数:41,代码来源:admin_server.py

示例6: __init__

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def __init__(self, template, routes):
        """Initializes a URL route.

        :param template:
            A route template to match against ``environ['SERVER_NAME']``.
            See a syntax description in :meth:`webapp2.Route.__init__`.
        :param routes:
            A list of :class:`webapp2.Route` instances.
        """
        super(DomainRoute, self).__init__(routes)
        self.template = template 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:13,代码来源:routes.py

示例7: _get_redirect_route

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def _get_redirect_route(self, template=None, name=None):
        template = template or self.template
        name = name or self.name
        defaults = self.defaults.copy()
        defaults.update({
            '_uri': self._redirect,
            '_name': name,
        })
        new_route = webapp2.Route(template, webapp2.RedirectHandler,
                                  defaults=defaults)
        return new_route 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:13,代码来源:routes.py

示例8: switch_to_dev_mode

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def switch_to_dev_mode():
    """Enables GS mock for a local dev server.

    Returns:
      List of webapp2.Routes objects to add to the application.
    """
    assert utils.is_local_dev_server(), 'Must not be run in production'
    if not URLSigner.DEV_MODE_ENABLED:
      # Replace GS_URL with a mocked one.
      URLSigner.GS_URL = (
          'http://%s/_gcs_mock/' % config.get_local_dev_server_host())
      URLSigner.GS_URL += '%(bucket)s/%(filename)s?%(query)s'
      URLSigner.DEV_MODE_ENABLED = True

    class LocalStorageHandler(webapp2.RequestHandler):
      """Handles requests to a mock GS implementation."""

      def get(self, bucket, filepath):
        """Read a file from a mocked GS, return 404 if not found."""
        try:
          with cloudstorage.open('/%s/%s' % (bucket, filepath), 'r') as f:
            self.response.out.write(f.read())
          self.response.headers['Content-Type'] = 'application/octet-stream'
        except cloudstorage.errors.NotFoundError:
          self.abort(404)

      def put(self, bucket, filepath):
        """Stores a file in a mocked GS."""
        with cloudstorage.open('/%s/%s' % (bucket, filepath), 'w') as f:
          f.write(self.request.body)

    endpoint = r'/_gcs_mock/<bucket:[a-z0-9\.\-_]+>/<filepath:.*>'
    return [webapp2.Route(endpoint, LocalStorageHandler)] 
开发者ID:luci,项目名称:luci-py,代码行数:35,代码来源:gcs.py

示例9: get_webapp2_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_webapp2_routes(cls):
    routes = cls.routes or [cls.navbar_tab_url]
    return [webapp2.Route(r, cls) for r in routes] 
开发者ID:luci,项目名称:luci-py,代码行数:5,代码来源:ui.py

示例10: test_get_authenticated_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def test_get_authenticated_routes(self):
    class Authenticated(handler.AuthenticatingHandler):
      pass

    class NotAuthenticated(webapp2.RequestHandler):
      pass

    app = webapp2.WSGIApplication([
      webapp2.Route('/authenticated', Authenticated),
      webapp2.Route('/not-authenticated', NotAuthenticated),
    ])
    routes = handler.get_authenticated_routes(app)
    self.assertEqual(1, len(routes))
    self.assertEqual(Authenticated, routes[0].handler) 
开发者ID:luci,项目名称:luci-py,代码行数:16,代码来源:handler_test.py

示例11: get_backend_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_backend_routes():
  """Returns a list of routes with task queue handlers.

  Used from ui/app.py (since it's where WSGI module is defined) and directly
  from auth_service backend module.
  """
  return [
    webapp2.Route(
        r'/internal/auth/taskqueue/process-change/<auth_db_rev:\d+>',
        InternalProcessChangeHandler),
  ] 
开发者ID:luci,项目名称:luci-py,代码行数:13,代码来源:change_log.py

示例12: get_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_routes(self, prefix=''):
    """Returns a list of webapp2.Route for all the routes the API handles."""
    return [
        webapp2.Route(
            '%s/prpc/<service>/<method>' % prefix,
            handler=self._handler(),
            methods=['POST', 'OPTIONS'])
    ] 
开发者ID:luci,项目名称:luci-py,代码行数:10,代码来源:server.py

示例13: get_backend_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_backend_routes():
  # This requires a cron job to this URL.
  return [
    webapp2.Route(
        r'/internal/cron/config/update', CronUpdateConfigs),
  ] 
开发者ID:luci,项目名称:luci-py,代码行数:8,代码来源:handlers.py

示例14: get_frontend_routes

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def get_frontend_routes():
  routes = [
    # Public API.
    webapp2.Route(
      '/ereporter2/api/v1/on_error', OnErrorHandler),
  ]
  if not utils.should_disable_ui_routes():
    routes.extend([
      webapp2.Route(
        r'/restricted/ereporter2/errors',
        RestrictedEreporter2ErrorsList),
      webapp2.Route(
        r'/restricted/ereporter2/errors/<error_id:\d+>',
        RestrictedEreporter2Error),
      webapp2.Route(
        r'/restricted/ereporter2/report',
        RestrictedEreporter2Report),
      webapp2.Route(
        r'/restricted/ereporter2/request/<request_id:[0-9a-fA-F]+>',
        RestrictedEreporter2Request),
      webapp2.Route(
        r'/restricted/ereporter2/silence',
        RestrictedEreporter2Silence),
    ])

  return routes 
开发者ID:luci,项目名称:luci-py,代码行数:28,代码来源:handlers.py

示例15: discovery_service_route

# 需要导入模块: import webapp2 [as 别名]
# 或者: from webapp2 import Route [as 别名]
def discovery_service_route(api_classes, base_path):
  """Returns a route to a handler which serves discovery documents.

  Args:
    api_classes: a list of protorpc.remote.Service classes the handler should
      know about.
    base_path: The base path under which all service paths exist.

  Returns:
    A webapp2.Route.
  """
  return webapp2.Route(
      '%s/discovery/v1/apis/<name>/<version>/rest' % base_path,
      discovery_handler_factory(api_classes, base_path)) 
开发者ID:luci,项目名称:luci-py,代码行数:16,代码来源:adapter.py


注:本文中的webapp2.Route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。