Flask-Once
Idempotent decorator for flask routes.
Inspired by stripe's idempotent endpoints.
Install
pip install flask-once
Usage
import uuid
from flask import Flask
from flask import jsonify
import flask_once
from flask_once import idempotent
app = Flask(__name__)
#: cache supports dict interface
app.cache = dict()
flask_once.attach(app, app.cache)
@app.route("/endpoint", methods=["POST"])
@idempotent()
def create_transaction():
uuid = str(uuid.uuid4())
return jsonify(transaction=uuid)
Test
pip install requirements-dev.txt
make test
Run example
Start app
python example.py
Curl endpoints
curl localhost:5000/endpoint \
-H 'Idempotent-Key: x'
Upload
make tag
TODO:
- Only cache routes with decorator.
- Add tests endpoints not wrapped in idempotency
Metadata
Release files for flask-once 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask-once-0.0.2.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_once-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / flask-once-0.0.2.tar.gz
| Download URL | flask-once-0.0.2.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cef816500ac8ed0ba51efdd9ca21ef81180173f2548bcdf9b6234b329f8bcbc
|
|
BLAKE2b-256 checksum How to use checksums |
4115e3b50637a593cd1c58924cedc6dc741872262f0bbc7cf3ee0c32c0d2fc13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Release files / flask_once-0.0.2-py3-none-any.whl
| Download URL | flask_once-0.0.2-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4cc3c1ed0d4ffdef311437167a2d64ad8bc5f9d082924b6eb20cb66133ddf06
|
|
BLAKE2b-256 checksum How to use checksums |
1788ac48738197de3d64f83a9e270d87beb2798c47ff7150e5d54feaff985f24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|