parameters: (requested_file)
return_statement: return web.Response(status=404)
docstring: Get file.
docstring_summary: Get file.
docstring_tokens: Get file .
function: async def get_file_response(requested_file):
      """Get file."""
      hacs = get_hacs()
  
      if requested_file in IGNORE:
          hacs.logger.debug(f"Ignoring request for {requested_file}")
          return web.Response(status=200)
  
      if requested_file.startswith("frontend-"):
          if hacs.configuration.debug:
              servefile = await hacs.hass.async_add_executor_job(locate_debug_gz)
              hacs.logger.debug("Serving DEBUG frontend")
          elif hacs.configuration.frontend_repo_url:
              hacs.logger.debug("Serving REMOTE DEVELOPMENT frontend")
              request = await hacs.session.get(f"{hacs.configuration.frontend_repo_url}/main.js")
              if request.status == 200:
                  result = await request.read()
                  response = web.Response(body=result)
                  response.headers["Cache-Control"] = "no-store, max-age=0"
                  response.headers["Pragma"] = "no-store"
                  return response
          elif hacs.configuration.frontend_repo:
              hacs.logger.debug("Serving LOCAL DEVELOPMENT frontend")
              servefile = f"{hacs.configuration.frontend_repo}/hacs_frontend/main.js"
          else:
              servefile = await hacs.hass.async_add_executor_job(locate_gz)
  
          if os.path.exists(servefile):
              response = web.FileResponse(servefile)
              if hacs.configuration.frontend_repo:
                  response.headers["Cache-Control"] = "no-store, max-age=0"
                  response.headers["Pragma"] = "no-store"
  
              return response
  
      elif requested_file == "iconset.js":
          return web.FileResponse(
              f"{hacs.system.config_path}/custom_components/hacs/iconset.js"
          )
  
      try:
          if requested_file.startswith("themes"):
              file = f"{hacs.system.config_path}/{requested_file}"
          else:
              file = f"{hacs.system.config_path}/www/community/{requested_file}"
  
          # Serve .gz if it exist
          if os.path.exists(file + ".gz"):
              file += ".gz"
  
          if os.path.exists(file):
              hacs.logger.debug("Serving {} from {}".format(requested_file, file))
              response = web.FileResponse(file)
              response.headers["Cache-Control"] = "no-store, max-age=0"
              response.headers["Pragma"] = "no-store"
              return response
          else:
              hacs.logger.error(f"Tried to serve up '{file}' but it does not exist")
  
      except Exception as error:  # pylint: disable=broad-except
          hacs.logger.debug(
              "there was an issue trying to serve {} - {}".format(requested_file, error)
          )
  
      return web.Response(status=404)
function_tokens: async def get_file_response ( requested_file ) : hacs = get_hacs ( ) if requested_file in IGNORE : hacs . logger . debug ( f"Ignoring request for {requested_file}" ) return web . Response ( status = 200 ) if requested_file . startswith ( "frontend-" ) : if hacs . configuration . debug : servefile = await hacs . hass . async_add_executor_job ( locate_debug_gz ) hacs . logger . debug ( "Serving DEBUG frontend" ) elif hacs . configuration . frontend_repo_url : hacs . logger . debug ( "Serving REMOTE DEVELOPMENT frontend" ) request = await hacs . session . get ( f"{hacs.configuration.frontend_repo_url}/main.js" ) if request . status == 200 : result = await request . read ( ) response = web . Response ( body = result ) response . headers [ "Cache-Control" ] = "no-store, max-age=0" response . headers [ "Pragma" ] = "no-store" return response elif hacs . configuration . frontend_repo : hacs . logger . debug ( "Serving LOCAL DEVELOPMENT frontend" ) servefile = f"{hacs.configuration.frontend_repo}/hacs_frontend/main.js" else : servefile = await hacs . hass . async_add_executor_job ( locate_gz ) if os . path . exists ( servefile ) : response = web . FileResponse ( servefile ) if hacs . configuration . frontend_repo : response . headers [ "Cache-Control" ] = "no-store, max-age=0" response . headers [ "Pragma" ] = "no-store" return response elif requested_file == "iconset.js" : return web . FileResponse ( f"{hacs.system.config_path}/custom_components/hacs/iconset.js" ) try : if requested_file . startswith ( "themes" ) : file = f"{hacs.system.config_path}/{requested_file}" else : file = f"{hacs.system.config_path}/www/community/{requested_file}" # Serve .gz if it exist if os . path . exists ( file + ".gz" ) : file += ".gz" if os . path . exists ( file ) : hacs . logger . debug ( "Serving {} from {}" . format ( requested_file , file ) ) response = web . FileResponse ( file ) response . headers [ "Cache-Control" ] = "no-store, max-age=0" response . headers [ "Pragma" ] = "no-store" return response else : hacs . logger . error ( f"Tried to serve up '{file}' but it does not exist" ) except Exception as error : # pylint: disable=broad-except hacs . logger . debug ( "there was an issue trying to serve {} - {}" . format ( requested_file , error ) ) return web . Response ( status = 404 )