mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-04-22 14:59:17 +00:00
Limiter func key with api key
This commit is contained in:
parent
c8f154561e
commit
6d43dfc504
1 changed files with 10 additions and 1 deletions
|
@ -257,8 +257,17 @@ def create_app(args):
|
||||||
else:
|
else:
|
||||||
return req_cost
|
return req_cost
|
||||||
|
|
||||||
|
def get_limits_key_func():
|
||||||
|
if args.api_keys:
|
||||||
|
def func():
|
||||||
|
ak = get_req_api_key()
|
||||||
|
return ak if ak else get_remote_address()
|
||||||
|
return func
|
||||||
|
else:
|
||||||
|
return get_remote_address
|
||||||
|
|
||||||
limiter = Limiter(
|
limiter = Limiter(
|
||||||
key_func=get_remote_address,
|
key_func=get_limits_key_func(),
|
||||||
default_limits=get_routes_limits(
|
default_limits=get_routes_limits(
|
||||||
args, api_keys_db
|
args, api_keys_db
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue