# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import run [as 別名]
def stuff_before_request():
if request.endpoint in ["get_doi_endpoint_v2", "get_doi_endpoint"]:
email = request.args.get("email", None)
if not email or email.endswith(u"example.com"):
abort_json(422, "Email address required in API call, see http://unpaywall.org/products/api")
if get_ip() in ["35.200.160.130", "45.249.247.101", "137.120.7.33",
"52.56.108.147", "193.137.134.252", "130.225.74.231"]:
abort_json(429, "History of API use exceeding rate limits, please email support@unpaywall.org for other data access options, including free full database dump.")
g.request_start_time = time()
g.hybrid = 'hybrid' in request.args.keys()
if g.hybrid:
logg