A Python Worker that creates short URLs backed by Workers KV.
Create a namespace, then replace the placeholder ID in wrangler.jsonc with the ID from the command output:
uv run pywrangler kv namespace create LINKSFirst ensure that uv is installed. Then run:
uv run pywrangler dev
curl -X POST http://localhost:8787/shorten \
-H 'content-type: application/json' \
-d '{"url":"https://example.com/path"}'The response includes a code, short_url, and the original url. Request the returned short URL to receive a 302 redirect. Deploy with uv run pywrangler deploy.
| Endpoint | Description |
|---|---|
POST /shorten |
Store an absolute HTTP(S) URL and return a short URL. |
GET /<code> |
Redirect to the stored URL with status 302. |