Idempotent Flask Endpoints
Project description
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
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-once-0.0.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for flask_once-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4cc3c1ed0d4ffdef311437167a2d64ad8bc5f9d082924b6eb20cb66133ddf06 |
|
MD5 | dfc069c42471d8123c353b7fa55f6d54 |
|
BLAKE2b-256 | 1788ac48738197de3d64f83a9e270d87beb2798c47ff7150e5d54feaff985f24 |