Python google.appengine.ext.webapp.WSGIApplication() Examples

The following are 30 code examples for showing how to use google.appengine.ext.webapp.WSGIApplication(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module google.appengine.ext.webapp , or try the search function .

Example 1
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: bulkload_deprecated.py    License: Apache License 2.0 6 votes vote down vote up
def main(*loaders):
  """Starts bulk upload.

  Raises TypeError if not, at least one Loader instance is given.

  Args:
    loaders: One or more Loader instance.
  """
  if not loaders:
    raise TypeError('Expected at least one argument.')

  for loader in loaders:
    if not isinstance(loader, Loader):
      raise TypeError('Expected a Loader instance; received %r' % loader)

  application = webapp.WSGIApplication([('.*', BulkLoad)])
  wsgiref.handlers.CGIHandler().run(application) 
Example 2
Project: browserscope   Author: elsigh   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_handlers_map():
  """Create new handlers map.

  Returns:
    list of (regexp, handler) pairs for WSGIApplication constructor.
  """
  pipeline_handlers_map = []

  if pipeline:
    pipeline_handlers_map = pipeline.create_handlers_map(prefix=".*/pipeline")

  return pipeline_handlers_map + [
      # Task queue handlers.
      (r".*/worker_callback", handlers.MapperWorkerCallbackHandler),
      (r".*/controller_callback", handlers.ControllerCallbackHandler),
      (r".*/kickoffjob_callback", handlers.KickOffJobHandler),
      (r".*/finalizejob_callback", handlers.FinalizeJobHandler),

      # RPC requests with JSON responses
      # All JSON handlers should have /command/ prefix.
      (r".*/command/start_job", handlers.StartJobHandler),
      (r".*/command/cleanup_job", handlers.CleanUpJobHandler),
      (r".*/command/abort_job", handlers.AbortJobHandler),
      (r".*/command/list_configs", status.ListConfigsHandler),
      (r".*/command/list_jobs", status.ListJobsHandler),
      (r".*/command/get_job_detail", status.GetJobDetailHandler),

      # UI static files
      (STATIC_RE, status.ResourceHandler),

      # Redirect non-file URLs that do not end in status/detail to status page.
      (r".*", RedirectHandler),
      ] 
Example 3
Project: browserscope   Author: elsigh   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_application():
  """Create new WSGIApplication and register all handlers.

  Returns:
    an instance of webapp.WSGIApplication with all mapreduce handlers
    registered.
  """
  return webapp.WSGIApplication(create_handlers_map(),
                                debug=True) 
Example 4
Project: earthengine   Author: mortcanty   File: appengine.py    License: MIT License 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 5
Project: locality-sensitive-hashing   Author: singhj   File: main.py    License: MIT License 5 votes vote down vote up
def create_handlers_map():
  """Create new handlers map.

  Returns:
    list of (regexp, handler) pairs for WSGIApplication constructor.
  """
  pipeline_handlers_map = []

  if pipeline:
    pipeline_handlers_map = pipeline.create_handlers_map(prefix=".*/pipeline")

  return pipeline_handlers_map + [
      # Task queue handlers.
      # Always suffix by mapreduce_id or shard_id for log analysis purposes.
      # mapreduce_id or shard_id also presents in headers or payload.
      (r".*/worker_callback.*", handlers.MapperWorkerCallbackHandler),
      (r".*/controller_callback.*", handlers.ControllerCallbackHandler),
      (r".*/kickoffjob_callback.*", handlers.KickOffJobHandler),
      (r".*/finalizejob_callback.*", handlers.FinalizeJobHandler),

      # RPC requests with JSON responses
      # All JSON handlers should have /command/ prefix.
      (r".*/command/start_job", handlers.StartJobHandler),
      (r".*/command/cleanup_job", handlers.CleanUpJobHandler),
      (r".*/command/abort_job", handlers.AbortJobHandler),
      (r".*/command/list_configs", status.ListConfigsHandler),
      (r".*/command/list_jobs", status.ListJobsHandler),
      (r".*/command/get_job_detail", status.GetJobDetailHandler),

      # UI static files
      (STATIC_RE, status.ResourceHandler),

      # Redirect non-file URLs that do not end in status/detail to status page.
      (r".*", RedirectHandler),
      ] 
Example 6
Project: locality-sensitive-hashing   Author: singhj   File: main.py    License: MIT License 5 votes vote down vote up
def create_application():
  """Create new WSGIApplication and register all handlers.

  Returns:
    an instance of webapp.WSGIApplication with all mapreduce handlers
    registered.
  """
  return webapp.WSGIApplication(create_handlers_map(),
                                debug=True) 
Example 7
Project: splunk-ref-pas-code   Author: splunk   File: appengine.py    License: Apache License 2.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 8
Project: sndlatr   Author: Schibum   File: appengine.py    License: Apache License 2.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 9
Project: billing-export-python   Author: googlearchive   File: appengine.py    License: Apache License 2.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 10
Project: googleapps-message-recall   Author: google   File: appengine.py    License: Apache License 2.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 11
Project: twitter-for-bigquery   Author: twitterdev   File: appengine.py    License: Apache License 2.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 12
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: ui.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  """Main program. Run the auth checking middleware wrapped WSGIApplication."""
  util.run_bare_wsgi_app(app) 
Example 13
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: _webapp25.py    License: Apache License 2.0 5 votes vote down vote up
def new_factory(cls, *args, **kwargs):
    """Create new request handler factory.

    Use factory method to create reusable request handlers that just
    require a few configuration parameters to construct.  Also useful
    for injecting shared state between multiple request handler
    instances without relying on global variables.  For example, to
    create a set of post handlers that will do simple text transformations
    you can write:

      class ChangeTextHandler(webapp.RequestHandler):

        def __init__(self, transform):
          self.transform = transform

        def post(self):
          response_text = self.transform(
              self.request.request.body_file.getvalue())
          self.response.out.write(response_text)

      application = webapp.WSGIApplication(
          [('/to_lower', ChangeTextHandler.new_factory(str.lower)),
           ('/to_upper', ChangeTextHandler.new_factory(str.upper)),
          ],
          debug=True)

    Text POSTed to /to_lower will be lower cased.
    Text POSTed to /to_upper will be upper cased.
    """
    def new_instance():
      return cls(*args, **kwargs)
    new_instance.__name__ = cls.__name__ + 'Factory'
    return new_instance 
Example 14
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: _webapp25.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, url_mapping, debug=False):
    """Initializes this application with the given URL mapping.

    Args:
      url_mapping: list of (URI regular expression, RequestHandler) pairs
                   (e.g., [('/', ReqHan)])
      debug: if true, we send Python stack traces to the browser on errors
    """
    self._init_url_mappings(url_mapping)
    self.__debug = debug


    WSGIApplication.active_instance = self
    self.current_request_args = () 
Example 15
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: _webapp25.py    License: Apache License 2.0 5 votes vote down vote up
def __call__(self, environ, start_response):
    """Called by WSGI when a request comes in."""
    request = self.REQUEST_CLASS(environ)
    response = self.RESPONSE_CLASS()


    WSGIApplication.active_instance = self


    handler = None
    groups = ()
    for regexp, handler_class in self._url_mapping:
      match = regexp.match(request.path)
      if match:
        try:
          handler = handler_class()



          handler.initialize(request, response)
        except Exception, e:
          if handler is None:
            handler = RequestHandler()
          handler.response = response
          handler.handle_exception(e, self.__debug)
          response.wsgi_write(start_response)
          return ['']
        groups = match.groups()
        break 
Example 16
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def CreateApplication():
  """Create new WSGIApplication and register all handlers.

  Returns:
    an instance of webapp.WSGIApplication with all mapreduce handlers
    registered.
  """
  return webapp.WSGIApplication([(r'.*', RedirectToAdminConsole)],
                                debug=True) 
Example 17
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: __init__.py    License: Apache License 2.0 5 votes vote down vote up
def get(self, prefix, name):
    """GET request handler.

    Typically the arguments are passed from the matching groups in the
    URL pattern passed to WSGIApplication().

    Args:
      prefix: The zipfilename without the .zip suffix.
      name: The name within the zipfile.
    """
    self.ServeFromZipFile(prefix + '.zip', name) 
Example 18
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: __init__.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  """Main program.

  This is invoked when this package is referenced from app.yaml.
  """
  application = webapp.WSGIApplication([('/([^/]+)/(.*)', ZipHandler)])
  util.run_wsgi_app(application) 
Example 19
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_handlers_map():
  """Create new handlers map.

  Returns:
    list of (regexp, handler) pairs for WSGIApplication constructor.
  """
  pipeline_handlers_map = []

  if pipeline:
    pipeline_handlers_map = pipeline.create_handlers_map(prefix=".*/pipeline")

  return pipeline_handlers_map + [



      (r".*/worker_callback.*", handlers.MapperWorkerCallbackHandler),
      (r".*/controller_callback.*", handlers.ControllerCallbackHandler),
      (r".*/kickoffjob_callback.*", handlers.KickOffJobHandler),
      (r".*/finalizejob_callback.*", handlers.FinalizeJobHandler),



      (r".*/command/start_job", handlers.StartJobHandler),
      (r".*/command/cleanup_job", handlers.CleanUpJobHandler),
      (r".*/command/abort_job", handlers.AbortJobHandler),
      (r".*/command/list_configs", status.ListConfigsHandler),
      (r".*/command/list_jobs", status.ListJobsHandler),
      (r".*/command/get_job_detail", status.GetJobDetailHandler),


      (STATIC_RE, status.ResourceHandler),


      (r".*", RedirectHandler),
      ] 
Example 20
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_application():
  """Create new WSGIApplication and register all handlers.

  Returns:
    an instance of webapp.WSGIApplication with all mapreduce handlers
    registered.
  """
  return webapp.WSGIApplication(create_handlers_map(),
                                debug=True) 
Example 21
Project: python-for-android   Author: kuri65536   File: blogapp.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  application = webapp.WSGIApplication([('/blogs', ListBlogs), 
                                        ('/write_post', WritePost)],
      debug=True)
  wsgiref.handlers.CGIHandler().run(application) 
Example 22
Project: python-for-android   Author: kuri65536   File: main_rsa.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  application = webapp.WSGIApplication([('/', MainPage),
                                        ('/get_oauth_token', OAuthDance),
                                        ('/fetch_data', FetchData),
                                        ('/revoke_token', RevokeToken)],
                                        debug=True)
  run_wsgi_app(application) 
Example 23
Project: python-for-android   Author: kuri65536   File: main_hmac.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  application = webapp.WSGIApplication([('/', MainPage),
                                        ('/get_oauth_token', OAuthDance),
                                        ('/fetch_data', FetchData),
                                        ('/revoke_token', RevokeToken)],
                                        debug=True)
  run_wsgi_app(application) 
Example 24
Project: appengine-mapreduce   Author: GoogleCloudPlatform   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_handlers_map():
  """Create new handlers map.

  Returns:
    list of (regexp, handler) pairs for WSGIApplication constructor.
  """
  pipeline_handlers_map = []

  if pipeline:
    pipeline_handlers_map = pipeline.create_handlers_map(prefix=".*/pipeline")

  return pipeline_handlers_map + [
      # Task queue handlers.
      # Always suffix by mapreduce_id or shard_id for log analysis purposes.
      # mapreduce_id or shard_id also presents in headers or payload.
      (r".*/worker_callback.*", handlers.MapperWorkerCallbackHandler),
      (r".*/controller_callback.*", handlers.ControllerCallbackHandler),
      (r".*/kickoffjob_callback.*", handlers.KickOffJobHandler),
      (r".*/finalizejob_callback.*", handlers.FinalizeJobHandler),

      # RPC requests with JSON responses
      # All JSON handlers should have /command/ prefix.
      (r".*/command/start_job", handlers.StartJobHandler),
      (r".*/command/cleanup_job", handlers.CleanUpJobHandler),
      (r".*/command/abort_job", handlers.AbortJobHandler),
      (r".*/command/list_configs", status.ListConfigsHandler),
      (r".*/command/list_jobs", status.ListJobsHandler),
      (r".*/command/get_job_detail", status.GetJobDetailHandler),

      # UI static files
      (STATIC_RE, status.ResourceHandler),

      # Redirect non-file URLs that do not end in status/detail to status page.
      (r".*", RedirectHandler),
      ] 
Example 25
Project: appengine-mapreduce   Author: GoogleCloudPlatform   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def create_application():
  """Create new WSGIApplication and register all handlers.

  Returns:
    an instance of webapp.WSGIApplication with all mapreduce handlers
    registered.
  """
  return webapp.WSGIApplication(create_handlers_map(),
                                debug=True) 
Example 26
Project: protorpc   Author: google   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  application = webapp.WSGIApplication([('/', MainHandler),
                                        ('/artists', ArtistsHandler),
                                        ('/artist', ArtistHandler),
                                        ('/update_artist', UpdateArtistHandler),
                                        ('/artist_action', ArtistActionHandler),
                                        ('/albums', AlbumsHandler),
                                        ('/album', AlbumHandler),
                                        ('/update_album', UpdateAlbumHandler),
                                        ('/album_action', AlbumActionHandler),
                                       ],
                                       debug=True)
  util.run_wsgi_app(application) 
Example 27
Project: protorpc   Author: google   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  path_info = os.environ.get('PATH_INFO', '')
  service_path, registry_path = parse_service_path(path_info)

  # Create webapp URL mappings for service and private registry.
  mapping = service_handlers.service_mapping(
    [(service_path, protorpc_appstats.AppStatsService)], registry_path)

  application = webapp.WSGIApplication(mapping)
  util.run_wsgi_app(application) 
Example 28
Project: protorpc   Author: google   File: main.py    License: Apache License 2.0 5 votes vote down vote up
def main():
  application = webapp.WSGIApplication([('/', MainHandler)],
                                       debug=True)
  util.run_wsgi_app(application) 
Example 29
Project: data   Author: jmankoff   File: appengine.py    License: GNU General Public License v3.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ]) 
Example 30
Project: data   Author: jmankoff   File: appengine.py    License: GNU General Public License v3.0 5 votes vote down vote up
def callback_application(self):
    """WSGI application for handling the OAuth 2.0 redirect callback.

    If you need finer grained control use `callback_handler` which returns just
    the webapp.RequestHandler.

    Returns:
      A webapp.WSGIApplication that handles the redirect back from the
      server during the OAuth 2.0 dance.
    """
    return webapp.WSGIApplication([
        (self.callback_path, self.callback_handler())
        ])