Flask-Whiteprint
Flask-Whiteprint is an enhancement of Flask-Blueprint.
Installation
Flask-Whiteprint is on development. I recommend NOT using it now.
Whiteprint-level Error Handler
Flask-Whiteprint supports whiteprint-level error handler for all exceptions include 404 and 500. I’ll remove that ending parentheses soon.
@blueprint.errorhandler()
def handle_error(e):
data = {
'error': {
'code': e.code,
'message': e.message
}
}
return Response(data, mimetype='application/json', status=e.status)
Dynamic Alias URL
You can alias url with alias method. Alias redirects without any redirect response (e.g. 301 or 302) and with all request context (e.g. HTTP Header, URL Variables or Form Data). This code redirects /me to /user/<int:id> with all request context.
@api.route('/me', methods=['GET', 'POST', 'PUT', 'DELETE'])
@api.route('/me/<path:path>', methods=['GET', 'POST', 'PUT', 'DELETE'])
@login_required
@jsoned
def redirect_me(path=''):
if 'path' in request.view_args:
request.view_args.pop('path')
user_path = '/user/%d/' % current_user.id + path
if user_path[-1] == '/':
user_path = user_path[:-1]
return api.alias(user_path, current_user.id)
Sub whiteprint (Not yet)
You can add child whiteprints to another whiteprint.
app (Flask Application)
|-- api (Parent whiteprint)
| |-- auth (Child whiteprint)
| | |-- login (Another child whiteprint)
| | `-- logout
| |-- user
| `-- post
|-- web (Another parent whiteprint)
| |-- auth
| |-- user
| `-- post
`-- admin
`-- admin
It looks awkward, but… just for an example!
Metadata
Release files for Flask-Whiteprint 0.0.1
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-Whiteprint-0.0.1.tar.gz | 4.3 kB | Without provenance | Details for Flask-Whiteprint-0.0.1.tar.gz |
Release files / Flask-Whiteprint-0.0.1.tar.gz
| Download URL | Flask-Whiteprint-0.0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34e9e319d3d0c69b72a26deb5b6d4f019a051045c9b3cafbcf63fd50e3610f30
|
|
BLAKE2b-256 checksum How to use checksums |
d82d7a12e3ff7a4e8c488ea179ec6865f24578fa4b13d39bebce1bbe812ba65a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-Whiteprint 0.0.1
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.