https://github.com/sjjian/flask-limit
flask limit redis
https://github.com/sjjian/flask-limit
flask
Last synced: 3 months ago
JSON representation
flask limit redis
- Host: GitHub
- URL: https://github.com/sjjian/flask-limit
- Owner: sjjian
- Created: 2017-09-22T16:01:20.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-22T16:26:17.000Z (almost 9 years ago)
- Last Synced: 2025-08-16T07:47:58.782Z (11 months ago)
- Topics: flask
- Language: Python
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## example
```python
from flask import session, jsonify
from limit import LimiterRedis
from redis import Redis
redis = Redis.from_url(url="redis://localhost:6379/0")
limiter = LimiterRedis(redis, "test")
def get_cookie():
return session.get("your_cookie_type")
def callback():
return jsonify("message"="request drop")
@app.route('/', methods=['GET', 'POST'])
@limiter.limit(get_cookie, "3/10", callback)
def hello_world(anything=None):
return jsonify("message"="request success")
```
## use
- "3/10" =>"3 count per 60 second"
- you can rewrite function create_count, get_count, incr_count by Inheritance LimiterMiXin, limit.py provide a redis classic.