Skip to main content

Bambu URL Shortener

This package generates short URLs when given longer ones. These can be generated by the app, with a 7 (by default) character short-name, or by an external provider, like bit.ly.

About Bambu Tools 2.0

This is part of a toolset called Bambu Tools. It’s being moved from a namespace of bambu to its own ‘root-level’ package, along with all the other tools in the set. If you’re upgrading from a version prior to 2.0, please make sure to update your code to use bambu_urlshortener rather than bambu.urlshortener.

Installation

Install the package via Pip:

pip install bambu-urlshortener

Add it to your INSTALLED_APPS list:

INSTALLED_APPS = (
    ...
    'bambu_urlshortener'
)

To use internal URL shortening - rather than a service like bit.ly - add the middleware to your settings:

MIDDLEWARE_CLASSES = (
    ...
    'bambu_urlshortener.middleware.ShortURLFallbackMiddleware'
)

This should be added as close to the end of your middleware list as possible, as it looks for 404 responses and tries to find a URL short-name corresponding to the requested path.

Run manage.py syncdb or manage.py migrate to setup the database tables.

Basic usage

Simply call bambu_urlshortener.shorten, passing in the long URL.

Providers

There are two in-built shortening providers:

bambu_urlshortener.providers.db.DatabaseProvider

This default option, coupled with the middleware allows a web app to provide its own short URLs.

bambu_urlshortener.providers.bitly.BitlyProvider

Calls the bit.ly API and returns a short URL. Specify the API key via the SHORTURL_TOKEN setting. Optionally set the SHORTURL_DOMAIN setting if you want to use a custom domain name.

Todo

  • Write more tests

Questions or suggestions?

Find me on Twitter (@iamsteadman) or visit my blog.

Metadata

Release files for bambu-urlshortener 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bambu-urlshortener 2.0
File Size Uploaded Provenance Actions
bambu-urlshortener-2.0.tar.gz 4.7 kB Without provenance Details for bambu-urlshortener-2.0.tar.gz

Release files / bambu-urlshortener-2.0.tar.gz

Download URL bambu-urlshortener-2.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ef076665a7626a3fab98b4cff5b8fea3976fb7bbc39440d12f37d4ec183032ad
BLAKE2b-256 checksum
How to use checksums
846519c8ad63b9b176e9c58727b6461961e4516440af543df6194d8c1b8ff69b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for bambu-urlshortener 2.0

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.

Release history Release notifications | RSS feed

This release

2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page