def route_get_artist(name): """ Search through our list of directories If match then return image from directory else return default image and fire google search """ global image_download_thread name.replace("/", "") if name in image_scraper.get_directory_names(): try: directory = "/Users/stevemurr/PycharmProjects/KCSMServer/images/" + name + "/" filename = name + "2.jpg_thumbnail.jpg" print(directory + filename) return send_from_directory(directory, filename, as_attachment=True) except: print("The image is probably being downloaded.") directory = "/Users/stevemurr/PycharmProjects/KCSMServer/images/KCSM/" filename = "KCSM2.jpg_thumbnail.jpg" print(directory + filename) return send_from_directory(directory, filename, as_attachment=True) else: directory = "/Users/stevemurr/PycharmProjects/KCSMServer/images/KCSM/" filename = "KCSM2.jpg_thumbnail.jpg" name = name.replace(' ', '%20') #urllib2.urlopen("http://localhost:5001/get_artist_images/" + name) return send_from_directory(directory, filename, as_attachment=True)
def route_get_detail_artist(name): """ Search through our list of directories If match then return image from directory else return default image and fire google search """ global image_download_thread name.replace("/", "") if name in image_scraper.get_directory_names(): directory = "/Users/stevemurr/PycharmProjects/KCSMServer/images/" + name + "/" filename = name + "1.jpg_detail.jpg" print(directory + filename) #print image_scraper.path + name + image_scraper.get_image_filename(name) return send_from_directory(directory, filename, as_attachment=True) #return send_from_directory(image_scraper.path, image_scraper.get_image_filename(name), as_attachment=True) else: directory = "/Users/stevemurr/PycharmProjects/KCSMServer/images/KCSM/" filename = "KCSM2.jpg_detail.jpg" print(directory + filename) return send_from_directory(directory, filename, as_attachment=True)