Skip to main content

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.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.

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.1.1.tar.gz (65.6 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.1.1-py2.7.egg (30.1 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for Flask-Limiter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 648879e693c3f62d5beb1ad827966b7fbd585d4104e7c78bbf2d1a7eff2f3da9
MD5 af337bfe188e09ef815dbbefb1c75d1e
BLAKE2b-256 8ac5e54ba7efb2299e48bd0ba7528a9333d192bf3def082e3e5738d76bb324fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Flask_Limiter-0.1.1-py2.7.egg
Algorithm Hash digest
SHA256 b80c43ddaa5c7c7551f0cf355ca0f52be3491e16aefef25b47a4e2152e98f01f
MD5 38d64de3653a78d2d1786672402884cd
BLAKE2b-256 1fc69eb6f43cee8f76f2a2ba61594f28f9961cf99b9ad6c8c1cb074e9f6a259b

See more details on using hashes here.

Release history Release notifications | RSS feed

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