Skip to main content

Rate limiting for flask applications

Project description

Flask-Limiter

travis-ci coveralls pypi

Flask-Limiter provides rate limiting features to flask routes. It has support for a configurable backend for storage with current implementations for in-memory, redis and memcache.

Quickstart

Add the rate limiter to your flask app. The following example uses the default in memory implementation for storage.

from flask import Flask
from flask_limiter import Limiter

app = Flask(__name__)
limiter = Limiter(app, global_limits=["2 per minute", "1 per second"])

@app.route("/slow")
@limiter.limit("1 per day")
def slow():
    return "24"

@app.route("/fast")
def fast():
    return "42"

app.run()

Test it out. The fast endpoint respects the global rate limit while the slow endpoint uses the decorated one.

$ curl localhost:5000/fast
42
$ curl localhost:5000/fast
42
$ curl localhost:5000/fast
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>429 Too Many Requests</title>
<h1>Too Many Requests</h1>
<p>2 per 1 minute</p>
$ curl localhost:5000/slow
24
$ curl localhost:5000/slow
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>429 Too Many Requests</title>
<h1>Too Many Requests</h1>
<p>1 per 1 day</p>

Read the docs

History

0.2.1 2014-02-15

  • python 2.6 support via counter backport

  • source docs.

0.2.1 2014-02-15

  • python 2.6 support via counter backport

  • source docs.

0.2 2014-02-15

  • Implemented configurable strategies for rate limiting.

  • Bug fixes

    • better locking for in-memory storage

    • multi threading support for memcached storage

0.1.1 2014-02-14

  • Bug fixes

    • fix initializing the extension without an app

    • don’t rate limit static files

0.1.0 2014-02-13

  • first release.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Limiter-0.2.1.tar.gz (101.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_Limiter-0.2.1-py2.7.egg (44.6 kB view details)

Uploaded Egg

File details

Details for the file Flask-Limiter-0.2.1.tar.gz.

File metadata

  • Download URL: Flask-Limiter-0.2.1.tar.gz
  • Upload date:
  • Size: 101.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Flask-Limiter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 da9f25a2d89bd0646123a2c02aafa37efa3de2c5db3ebd568e80ed56d1eaef1a
MD5 3e9308337fc5d5c07f7c09bd541b93a5
BLAKE2b-256 3848d648830306b75e7214baed3ca69444cfff0db6a52542852f4b51d9e0bc43

See more details on using hashes here.

File details

Details for the file Flask_Limiter-0.2.1-py2.7.egg.

File metadata

File hashes

Hashes for Flask_Limiter-0.2.1-py2.7.egg
Algorithm Hash digest
SHA256 fd368ee58f6d1e33bf06248b06c78f2021fde2c25e22ec1c563efcec4dd0fd59
MD5 97bcb50589c8df38be447d0103052c73
BLAKE2b-256 7bcb6291204b6817b2af42fe49857357a2276d37a228d08951cee5944a4e4991

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page