コード例 #1
0
ファイル: endpoints.py プロジェクト: Foxboron/Photofloat
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
コード例 #2
0
ファイル: endpoints.py プロジェクト: sum12/PhotoFloat
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
コード例 #3
0
ファイル: endpoints.py プロジェクト: sum12/PhotoFloat
def check_permissions(path):
    if not is_authenticated():
        for auth_path in auth_list:
            if path.startswith(auth_path):
                abort(403)
コード例 #4
0
ファイル: endpoints.py プロジェクト: Foxboron/Photofloat
def check_permissions(path):
	if not is_authenticated():
		for auth_path in auth_list:
			if path.startswith(auth_path):
				abort(403)