Пример #1
0
def api_percentage(percentage):
    include_upv4_only = (
        False
        if request.args.get("include_ipv4_only_trackers", default="true").lower()
        in ("false", "0")
        else True
    )
    include_upv6_only = (
        False
        if request.args.get("include_ipv6_only_trackers", default="true").lower()
        in ("false", "0")
        else True
    )
    if 0 <= percentage <= 100:
        formatted_list = db.get_api_data(
            "percentage", percentage, include_upv4_only, include_upv6_only
        )
        resp = make_response(formatted_list)
        resp = utils.add_api_headers(resp)
        return resp
    else:
        abort(
            Response(
                "The percentage has to be between 0 an 100",
                400,
                headers={"Access-Control-Allow-Origin": "*"},
            )
        )
Пример #2
0
def api_multiple():
    resp = make_response(db.get_api_data(request.path))
    resp = utils.add_api_headers(resp)
    return resp