def ServeStaticFile(self, matcher, appinfo_external, unused_env,
                      start_response):
    static_files = appinfo_external.static_files
    static_dir = appinfo_external.static_dir
    if static_files:
      filename = matcher.expand(static_files)
    elif static_dir:
      x = matcher.end()
      path = matcher.string
      static_dir = static_dir.lstrip('/')
      filename = static_dir + path[x:]
    filename = os.path.abspath(filename)
    pwd = os.getcwd()
    if not filename.startswith(os.path.join(pwd, '')):
      logging.warn('Requested bad filename %r', filename)
      start_response('404 Not Found', [])
      return
    try:
      fp = open(filename, 'rb')
    except IOError:
      logging.warn('Requested non-existent filename %r', filename)
      start_response('404 Not Found', [])
      return
    try:
      encoding = None
      mime_type = appinfo_external.mime_type
      if not mime_type:
        mime_type, encoding = mimetypes.guess_type(filename)
      headers = []
      if mime_type:
        headers.append(('Content-Type', mime_type))
      if encoding:
        headers.append(('Content-Encoding', encoding))

      start_response('200 OK', headers)
      while True:
        data = fp.read(8192)
        if not data:
          break
        yield data
    finally:
      fp.close()
Serve a static file.
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/ext/vmruntime/meta_app.py/MetaWSGIApp.ServeStaticFile