This project is a rate limiter for Flask, and allows you to apply rate limit rules to routes, blueprints, or apply global limits that affect all routes.
- Sliding window
This project is registered with PyPi, and can be installed with
pip install flask_rlmt- Import flask_rlmt
import flask_rlmt- Create a new limiter
app = Flask(__name__)
limiter = Limiter(
app=app,
rules=[
"10 per minute",
"100 per hour"
]
)- Add rules to an individual route
@app.route("/")
@limiter.guard(rules=["1000/d"])
def home():- Apply rules to an entire blueprint
auth_bp = Blueprint('auth', __name__, url_prefix='/auth')
limiter.apply(auth_bp, rules=["2 per 10s"])
app.register_blueprint(auth_bp)For further questions on how to interact with the API, please refer to the docs/QUICKSTART.md.