Flask-RateLimiter is a Flask extension that provides rate limiting decorator.
Flask-RateLimiter is on PyPI so all you need is:
$ pip install flask-ratelimiter
The development version can be downloaded from its page at GitHub.
$ git clone https://github.com/inveniosoftware/flask-ratelimiter.git
$ cd flask-ratelimiter
$ python setup.py develop
$ ./run-tests.sh
This documentation section is automatically generated from Flask-RateLimiter’s source code.
Extension for Flask that adds support for request rate limiting.
Flask-RateLimiter is initialized like this:
>>> from flask import Flask
>>> from flask_ratelimiter import RateLimiter
>>> app = Flask('myapp')
>>> ext = RateLimiter(app=app)
You can use ratelimit decorator like this:
>>> from flask_ratelimiter import ratelimit
>>>
>>> @ratelimit(300, 200)
>>> def some_view():
>>> return 'HelloWorld'
It is based on snippet of code by Armin Ronacher from http://flask.pocoo.org/snippets/70/.
Implement RateLimiter extension.
Initialization of the extension can be done via following code:
>>> from flask import Flask
>>> from flask_ratelimiter import RateLimiter
>>> app = Flask('myapp')
>>> ext = RateLimiter(app=app)
or alternatively using the factory pattern:
>>> app = Flask('myapp')
>>> ext = RateLimiter()
>>> ext.init_app(app)
Return backend for RateLimiter.
If there is no such backend, default backend will be returned.
Initialize a Flask extension.
Here you can see the full list of changes between each Flask-RateLimiter release.
Version 0.2.0 (released 2014-12-16)
Version 0.1.0 (released 2014-06-27)
Bug reports, feature requests, and other contributions are welcome. If you find a demonstrable problem that is caused by the code of this library, please:
If you create a feature branch, you can run the tests to ensure everything is operating correctly:
$ ./run-tests.sh
Flask-RateLimiter is free software; you can redistribute it and/or modify it under the terms of the Revised BSD License quoted below.
Copyright (C) 2013, 2014 CERN.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction.
Flask-RateLimiter is developed for use in Invenio digital library software.
Contact us at info@invenio-software.org