(self, request, requested_file)
return response
Serve plugins for lovelace.
Serve plugins for lovelace.
Serve plugins for lovelace .
async def get(self, request, requested_file):  # pylint: disable=unused-argument
        """Serve plugins for lovelace."""
        try:
            # Strip '?' from URL
            if "?" in requested_file:
                requested_file = requested_file.split("?")[0]

            file = f"{self.system.config_path}/www/community/{requested_file}"

            # Serve .gz if it exist
            if os.path.exists(file + ".gz"):
                file += ".gz"

            response = None
            if os.path.exists(file):
                self.logger.debug("Serving {} from {}".format(requested_file, file))
                response = web.FileResponse(file)
                response.headers["Cache-Control"] = "max-age=0, must-revalidate"
            else:
                self.logger.error(f"Tried to serve up '{file}' but it does not exist")
                response = web.Response(status=404)

        except Exception as error:  # pylint: disable=broad-except
            self.logger.debug(
                "there was an issue trying to serve {} - {}".format(
                    requested_file, error
                )
            )
            response = web.Response(status=404)

        return response
async def get ( self , request , requested_file ) : # pylint: disable=unused-argument try : # Strip '?' from URL if "?" in requested_file : requested_file = requested_file . split ( "?" ) [ 0 ] file = f"{self.system.config_path}/www/community/{requested_file}" # Serve .gz if it exist if os . path . exists ( file + ".gz" ) : file += ".gz" response = None if os . path . exists ( file ) : self . logger . debug ( "Serving {} from {}" . format ( requested_file , file ) ) response = web . FileResponse ( file ) response . headers [ "Cache-Control" ] = "max-age=0, must-revalidate" else : self . logger . error ( f"Tried to serve up '{file}' but it does not exist" ) response = web . Response ( status = 404 ) except Exception as error : # pylint: disable=broad-except self . logger . debug ( "there was an issue trying to serve {} - {}" . format ( requested_file , error ) ) response = web . Response ( status = 404 ) return response