fix: Poprawka składni @limiter.request_filter dla Flask-Limiter 4.0
This commit is contained in:
parent
d785b5094f
commit
009cd09492
16
app.py
16
app.py
@ -246,6 +246,14 @@ try:
|
||||
except Exception:
|
||||
logger.warning("Redis unavailable, rate limiter using memory storage")
|
||||
|
||||
limiter = Limiter(
|
||||
app=app,
|
||||
key_func=get_remote_address,
|
||||
default_limits=["200 per day", "50 per hour"],
|
||||
storage_uri="redis://localhost:6379/0" if _redis_available else "memory://"
|
||||
)
|
||||
|
||||
@limiter.request_filter
|
||||
def is_admin_exempt():
|
||||
"""Exempt logged-in admins from rate limiting."""
|
||||
from flask_login import current_user
|
||||
@ -254,14 +262,6 @@ def is_admin_exempt():
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
limiter = Limiter(
|
||||
app=app,
|
||||
key_func=get_remote_address,
|
||||
default_limits=["200 per day", "50 per hour"],
|
||||
storage_uri="redis://localhost:6379/0" if _redis_available else "memory://",
|
||||
request_filter=is_admin_exempt # Admins are exempt from rate limits
|
||||
)
|
||||
|
||||
# Initialize database
|
||||
init_db()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user