Flask-UUID
Flask-UUID is a simple Flask extension that registers a UUID converter for urls on a Flask application. It uses the standard library’s uuid module to convert UUIDs to and from strings.
This extension allows you to easily route and generate urls containing UUID, e.g. /page/fe4a3e33-cb4b-42ac-a29b-a8160a85af7e.
Installation
Installation is trivial:
$ pip install Flask-UUID
Usage
Flask-UUID is a well-behaved Flask extension, so you can either initialise it directly upon instantiation:
from flask import Flask from flask.ext.uuid import FlaskUUID app = Flask(__name__) FlaskUUID(app)
Or initialise it like this:
from flask import Flask from flask.ext.uuid import FlaskUUID app = Flask(__main__) flask_uuid = FlaskUUID() flask_uuid.init_app(app)
Now you can use it in your routes like any other converter:
@app.route('/<uuid:id>')
def mypage(id):
return id # 'id' is a uuid.UUID instance
You can also use UUID instances to generate urls:
random_uuid = uuid.uuid4()
url = app.url_for('mypage', id=random_uuid)
Note that, by default, the converter only accepts and generates lowercase hexadecimal UUIDs with dashes at the proper places, in order to keep urls unique. If you want to accept any UUID string accepted by the uuid.UUID() constructor, simply set the strict flag to False:
@app.route('/<uuid(strict=False):id>'>
def mypage(id):
return id
License
This software is BSD licensed; see LICENSE.rst for more information.
Metadata
Release files for Flask-UUID 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 | Provenance | Actions |
|---|---|---|---|---|
| Flask-UUID-0.2.tar.gz | 2.0 kB | Without provenance | Details for Flask-UUID-0.2.tar.gz |
Release files / Flask-UUID-0.2.tar.gz
| Download URL | Flask-UUID-0.2.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9a8196eb896599ba9e74dcf713cfd1aca4669d418c19069e088620ae6294805
|
|
BLAKE2b-256 checksum How to use checksums |
1e17ed38fb7a9d7685bb1553dc3c1c6acd0bc960cb8935ad432e58665a7802e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-UUID 0.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.