Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flask api limiter issue #318

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web/conceptnet_web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import flask
from flask_cors import CORS
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

from conceptnet5 import api as responses
from conceptnet5.api import VALID_KEYS, error
Expand Down Expand Up @@ -37,7 +38,8 @@ def app_path(path):
for filter_name, filter_func in FILTERS.items():
app.jinja_env.filters[filter_name] = filter_func
app.jinja_env.add_extension('jinja2_highlight.HighlightExtension')
limiter = Limiter(app, global_limits=["600 per minute", "6000 per hour"])
limiter = Limiter(app, key_func=get_remote_address,
global_limits=["600 per minute", "6000 per hour"])
CORS(app)
try_configuring_sentry(app)
application = app # for uWSGI
Expand Down
2 changes: 1 addition & 1 deletion web/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
include_package_data=True,
install_requires=[
'conceptnet >= %s' % version_str,
'limits', 'flask >= 0.12.3', 'flask-cors', 'flask-limiter',
'limits', 'flask >= 2.0.2', 'flask-cors >=3.0.10', 'flask-limiter == 2.0.2',
'langcodes >= 2.1', 'jinja2-highlight', 'pygments', 'raven[flask] >= 6.6'
],
license = 'Apache License 2.0',
Expand Down