flask-skinny
A Flask extension that forces extremely skinny controllers.
@app.route("/dogs/<int:dog_id>", methods=["POST"])
@skinny.responses({200: responses.greet_dog, 400: responses.bad_request})
@skinny.intent(intents.greet_dog)
def greet_dog(dog_id):
pass
Description
This extension contains two decorators, @skinny.intent and @skinny.responses.
@skinny.intent(callable)callable: Receivesflask.request, returnsstatus_codeandoutcome.
@skinny.responses({status_code: callable, ...})callable: Receivesflask.requestandoutcome, returnsheadersandbody.
@skinny.responses will choose an appropriate response by status_code.
Simple Usage
from flask import Flask
from flask_skinny import skinny
from random import randint
import json
def intent(request):
if randint(0, 1) == 0:
status_code = 200
outcome = "OK"
else:
status_code = 403
outcome = "Forbidden"
return status_code, outcome
def response(request, outcome):
headers = {"content-type": "application/json"}
body = json.dumps({"message": outcome}) + "\n"
return headers, body
app = Flask(__name__)
@app.route("/", methods=["GET"])
@skinny.responses({200: response, 403: response})
@skinny.intent(intent)
def index():
pass
Detailed Usage
See app.py.
Installation
$ pip install flask-skinny
Contribution
Create new Pull Request.
License
Metadata
Release files for flask-skinny 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| flask-skinny-0.1.2.tar.gz | 2.6 kB | Without provenance | Details for flask-skinny-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_skinny-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for flask_skinny-0.1.2-py3-none-any.whl |
Total release size: 6.1 kB
Release files / flask-skinny-0.1.2.tar.gz
| Download URL | flask-skinny-0.1.2.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d0dffcadb4342c1969cdd7c91d6716204ecc4bca5c322158937d1e1fed52748
|
|
BLAKE2b-256 checksum How to use checksums |
54bc9502e931001949f8689d4f4a80755192deca65354956ab70f44952f05d0f
|
| 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/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Release files / flask_skinny-0.1.2-py3-none-any.whl
| Download URL | flask_skinny-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47be312ecdc2bae44e05d49d3656f70869689730bc23a807d6ad4e013293bf02
|
|
BLAKE2b-256 checksum How to use checksums |
bc763fc63b35a7ba3f9514261efcce1d478ae8e5f815818776a14f6ee5015d0f
|
| 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/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Security for flask-skinny 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.