Better Fix for flask limiter 4.0

This commit is contained in:
Ozzie Isaacs
2026-02-18 19:11:38 +01:00
parent e3bf369ad6
commit fbed304df8
3 changed files with 45 additions and 38 deletions

View File

@@ -46,10 +46,11 @@ def main():
try:
from .kobo import kobo, get_kobo_activated
from .kobo_auth import kobo_auth
from flask_limiter.util import get_remote_address
kobo_available = get_kobo_activated()
except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator)
kobo_available = False
kobo = kobo_auth = None
kobo = kobo_auth = get_remote_address = None
try:
from .oauth_bb import oauth
@@ -76,6 +77,7 @@ def main():
app.register_blueprint(gdrive)
app.register_blueprint(editbook)
if kobo_available:
limiter.limit("3/minute", key_func=get_remote_address)(kobo)
app.register_blueprint(kobo)
app.register_blueprint(kobo_auth)
if oauth_available: