Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

Flask-UUID

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Flask-UUID

UUID url converter for Flask routes

  • 0.2
  • PyPI
  • Socket score

Maintainers
1

========== 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.

.. _Flask: http://flask.pocoo.org

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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc