def get(self, icon_hash): apiResponse = ApiResponse() icon = icons.getImageData(icon_hash) if (icon): icon.update({"request": icon_hash}) apiResponse.setAll(False, "Image found", icon) else: apiResponse.setAll(True, "Image not found", {"request": icon_hash}) return apiResponse.getResponse()
def get(self, query, limit): apiResponse = ApiResponse() icons.updateImages() icons_found = icons.searchImages(query, limit) apiResponse.setError(False if (len(icons_found)) else True) apiResponse.setMessage( str(len(icons_found)) + " images found for your query" if ( len(icons_found)) else "No image found for that query") apiResponse.setDetails(icons_found) return apiResponse.getResponse()
def wrapper(*args, **kwargs): response = ApiResponse() if "X-Api-Auth-Token" in request.headers: token_value = escape(request.headers["X-Api-Auth-Token"]) response = AuthService.checkToken(token_value) if response.error is False: response = AuthService.renewToken(token_value) else: response.setMessage( "Missing token in header of the query : X-Api-Auth-Token") if response.error is True: return response.getResponse() else: return f(*args, **kwargs)
def get(self): apiResponse = ApiResponse() apiResponse.setAll(False, "Everything's up and running", {}) return apiResponse.getResponse()
def get(self): apiResponse = ApiResponse() apiResponse.setAll(False, "Everything's up and running", {"nb_images": len(icons.getImagesData())}) return apiResponse.getResponse()