def photos(): f = open(os.path.join(app.config["CACHE_PATH"], "all_photos.json"), "r") photos = json.load(f) f.close() if not is_authenticated(): def allowed(photo): for auth_path in auth_list: if photo.startswith(auth_path): return False return True photos = [photo for photo in photos if allowed(photo)] count = int(request.args.get("count", len(photos))) random = request.args.get("random") == "true" if random: shuffle(photos) else: photos.reverse() response = jsonify(photos=photos[0:count]) response.cache_control.no_cache = True return response
def check_permissions(path): if not is_authenticated(): for auth_path in auth_list: if path.startswith(auth_path): abort(403)