def get_thumbnails(): """Get images in JSON format.""" return jsonify({ 'error': None, 'message': "Success", 'thumbnails': get_images() })
def thumbnail(): url = "https://www.walmart.com/ip/54649026" imagelist = get_images(url) for each in imagelist: if not each.lower().endswith(('.png', '.jpg', '.jpeg')): imagelist.remove(each) imagelist = list(set(imagelist)) output = jsonify(error="null", message="Success", thumbnails=imagelist) return output
def scrapeImages(): """Accepts a url and returns JSON containing a list of thumbnails.""" if request.is_json: Webpage = request.get_json(force=True) print Webpage["url"] images = { "error": "null", "message": "Success", "thumbnails": get_images(Webpage["url"]) } print "success" else: images = { "error": "true", "data": {}, "message": "Unable to extract thumbnails" } print "failed" print "returning" return jsonify(images)
def api_thumbnails(): user = auth_user(request.authorization) if user is None: output = { "error": True, "data": {}, "message": "Authorization failure" } else: if 'url' not in request.args: output = { "error": True, "data": {}, "message": "Invalid request format" } else: data = {"thumbnails": get_images(request.args.get('url'))} output = {"error": None, "data": data, "message": "Success"} return json.dumps(output, indent=4, sort_keys=True)
def api_thumbnails(): output = {"error": None, "message": "Success", "thumbnails": get_images()} return json.dumps(output, indent=4, sort_keys=True)
def images(): """Returns JSON of links to all images on a website's page.""" images = {"error": "null", "message":"Success","thumbnails": get_images()} return jsonify(images)
def thumbnails(url): return jsonify(error=None, message="Success", thumbnails=image_getter.get_images(url))