request_limiter 0.1.1

Creator: railscoderz

Last updated:

0 purchases

request_limiter 0.1.1 Image
request_limiter 0.1.1 Images

Languages

Categories

Add to Cart

Description:

request limiter 0.1.1

Request Limiter



Request limiter contains a decorator to limit the rate of http request

Free software: MIT license
Documentation: https://request-limiter.readthedocs.io.


Features

A decorator to limit django http request
A strategy to limit request per interval using requester IP



Get started
Installation:
$ pip install request_limiter
Limit request to django view using a decorator:
from request_limiter import request_limiter, LimitedIntervalStrategy, django_request_limiter

@django_request_limiter
@request_limiter(strategy=LimitedIntervalStrategy(requests=10, interval=60)) # 10 request per minute
def myview(request):
# ...
Limit the number of request to function or part of it:
from request_limiter import request_limiter, LimitedIntervalStrategy, LimitException

@request_limiter(strategy=LimitedIntervalStrategy(requests=1, interval=60)) # 1 request per minute
def awesome_work(param):
# ...

awesome_work("test")
try:
awesome_work("limited") # raises LimitException
except LimitException:
# .. handle limit exception

limiter = LimitedIntervalStrategy(requests=1, interval=60)) # 1 request per minute

def another_work(param):
if not limiter.allow():
return False
# ...
return True

another_work("job1") # returns True
another_work("job2") # returns False


Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.



History
0.1.1 (2020-01-14)

First release on PyPI.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.