Skip to main content

File based url shortening

Project description

smolu

Self-hosted url shortening for individual use.

The is a very simple file-based redirection generator producing unique short urls.

It has to be used with an existing http static file server.

Installation

git clone https://git.sr.ht/~lattay/smolu
cd smolu
pip install .

Optionally you want to install qrencode to be able to generate QR codes.

Usage

  1. Configure the http server to serve the /srv/http/u/ directory statically, serving everything as html unconditionally.

Caddy config:

example.com:443 {
	root * /srv/http
	@html {
		path /u/*
		not path *.png
	}
	header @html Content-Type "text/html; charset=utf-8"
	file_server
}

Nginx config:

server {
    listen 443 ssl;
    server_name example.com;

    root /srv/http;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location ~ ^/u/.*\.png$ {
        # nothing special
    }

    location /u/ {
        add_header Content-Type "text/html; charset=utf-8";
    }
}

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}
  1. Run smolu.py -C to initialize the configuration

  2. To add a new short address, run smolu.py <target>, it will print the short url to stdout. If enabled, the QR code will be found at <short_url>.png

Note: this is designed for individual user, meaning it is not designed for millions of urls, or for super fast generation. It will check for collisions though (in a parallel unsafe way though, again a single user won't have a problem). The default is to use 6 bytes of timestamp and 6 random bytes, however even 2+1 should be just fine for personal use. The bytes are base64 encoded so for each 3 bytes of the id, you get 4 characters in the url.

Also, you need a short domain name, otherwise it really does not make sense.

Features

  • Opt-in QR code generation
  • Configurable short url length
  • No SEO
  • No analytics
  • No tracking
  • No ads
  • No time limit
  • Free and open source
  • Self-hosted
  • No database
  • No longrunning process (apart from whatever http server you are running)
  • No attack surface (assuming you are using a production grade http server such as nginx or caddy with TLS enabled)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smolu-0.2.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smolu-0.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file smolu-0.2.0.tar.gz.

File metadata

  • Download URL: smolu-0.2.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for smolu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bc76d699c62c456e81ae0ce5beb0af9f40191bede2d69beade24b5014bfd0409
MD5 9c00b2fb96951c285d4abf4c7b4a8489
BLAKE2b-256 759381e7b43d22407259109527cd7812895259c68f5c69ccd7d2cd644294a303

See more details on using hashes here.

File details

Details for the file smolu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: smolu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for smolu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67ecfbfb0f432704d00459fb26fb0d52caf3ab9994ab14ac606c8cff17fcd5fd
MD5 743ca4e7a9a84458aedf6714cc90b62e
BLAKE2b-256 3d5e31e6745583e7f9b2c339296353e47915ad3e256438ceaa9004e5b098c1a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page