Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

mkurl

A command-line utility to create and manage short URLs backed by S3 objects. Each shortcode is stored as an S3 object whose content is the target long URL.

How it works

mkurl stores shortcodes as plain-text objects in an S3 bucket:

s3://<BUCKET>/<PREFIX><shortcode>   →   contents: "https://long-url.example.com"

A separate URL expander (running on your web server) reads these objects to perform the actual redirects.

Configuration

Edit the constants near the top of the mkurl script:

BUCKET        = "your-bucket-name"   # S3 bucket holding the shortcodes
PREFIX        = "urls/"              # S3 key prefix
BASE_URL      = "http://hpc.news/"   # Base URL of your expander service
RANDOM_DIGITS = 3                    # Digits appended in -R mode (wordNNN)

Installation

chmod +x mkurl
cp mkurl ~/bin/          # or /usr/local/bin, anywhere on your PATH
pip install boto3        # if not already installed

AWS credentials are resolved via the standard boto3 chain (~/.aws/credentials, environment variables, IAM role, etc.).

Usage

Create a shortcode explicitly

mkurl -s goog -l https://google.com
# → http://hpc.news/goog

Overwrite an existing shortcode

mkurl -s goog -l https://google.co.uk -F
# → http://hpc.news/goog

Create a shortcode with a random suffix

mkurl -R news -l https://example.com/some/long/path
# → http://hpc.news/news042   (or whatever unused wordNNN is found)

List all shortcodes

Output is TSV: shortcode <tab> short URL <tab> long URL

mkurl -L
# goog    http://hpc.news/goog    https://google.com
# news042 http://hpc.news/news042 https://example.com/some/long/path

Look up a specific shortcode

mkurl -L goog
# goog    http://hpc.news/goog    https://google.com

Flags

Flag Description
-s SHORTCODE Explicit shortcode to create
-l URL Long URL to store (required when creating)
-R WORD Generate a random shortcode of the form WORDnnn
-F Force-overwrite an existing shortcode
-L [SHORTCODE] List all mappings (sorted), or one specific one

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages