(self, request, endpoint)
return response
Handle HACS API requests.
Handle HACS API requests.
Handle HACS API requests .
async def post(self, request, endpoint):  # pylint: disable=unused-argument
        """Handle HACS API requests."""
        if self.system.disabled:
            return web.Response(status=404)
        self.endpoint = endpoint
        self.postdata = await request.post()
        self.raw_headers = request.raw_headers
        self.request = request
        self.logger.debug(f"Endpoint ({endpoint}) called")
        if self.configuration.dev:
            self.logger.debug(f"Raw headers ({self.raw_headers})")
            self.logger.debug(f"Postdata ({self.postdata})")
        if self.endpoint in APIRESPONSE:
            try:
                response = APIRESPONSE[self.endpoint]
                response = await response.response(self)
            except Exception as exception:
                render = self.render(f"error", message=exception)
                return web.Response(
                    body=render, content_type="text/html", charset="utf-8"
                )
        else:
            # Return default response.
            response = await APIRESPONSE["generic"].response(self)

        # set headers
        response.headers["Cache-Control"] = "max-age=0, must-revalidate"

        # serve the response
        return response
async def post ( self , request , endpoint ) : # pylint: disable=unused-argument if self . system . disabled : return web . Response ( status = 404 ) self . endpoint = endpoint self . postdata = await request . post ( ) self . raw_headers = request . raw_headers self . request = request self . logger . debug ( f"Endpoint ({endpoint}) called" ) if self . configuration . dev : self . logger . debug ( f"Raw headers ({self.raw_headers})" ) self . logger . debug ( f"Postdata ({self.postdata})" ) if self . endpoint in APIRESPONSE : try : response = APIRESPONSE [ self . endpoint ] response = await response . response ( self ) except Exception as exception : render = self . render ( f"error" , message = exception ) return web . Response ( body = render , content_type = "text/html" , charset = "utf-8" ) else : # Return default response. response = await APIRESPONSE [ "generic" ] . response ( self ) # set headers response . headers [ "Cache-Control" ] = "max-age=0, must-revalidate" # serve the response return response