CloudFiles as a URL Shortner

cfshorty is the ghetto URL Shortner running at that was inspired by this engineering blog post

Its built with Flask and Swiftly and uses the Rackspace CloudFiles object store Tiny tiny objects.

It works by turning a long url into a short code through magic! Well, its not magic as much it is abusing sha256 in this case.

A basic html page with the short code as its name is uploaded as an object to CloudFiles, and served up via the CDN. This allows you to expand url's directly. You're not dependent on the url shortner app being up and running. As long as CloudFiles and the CDN are up you can expand url's by going to url like

As I mentioned, the contents of the uploaded object is just a simple HTML page that redirects a visitor the original long url when its accessed requested via the CDN:

[email protected]:~$ http  
HTTP/1.1 200 OK  
Accept-Ranges: bytes  
Cache-Control: public, max-age=259160  
Connection: keep-alive  
Content-Encoding: gzip  
Content-Length: 274  
Content-Type: text/html  
Date: Mon, 07 Oct 2013 07:10:56 GMT  
ETag: b592164ee9183282f9b2259d154d23cf  
Expires: Thu, 10 Oct 2013 07:10:16 GMT  
Last-Modified: Mon, 07 Oct 2013 06:41:14 GMT  
Vary: Accept-Encoding  
X-Timestamp: 1381128074.94653  
X-Trans-Id: txb4163f76b17c4753bc188-0052525e7fdfw1

<html lang="en-US">  
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="1; url=">
        window.location.href = ""
    <title> - Page Redirection</title>
If you are not redirected automatically to <a href=''></a> follow <a href=''>this link</a>  

In addition, when the object is stored in CloudFiles a meta data key called "X-Object-Meta-Longurl" is also set pointing to the original url. This allows you to determine the long url of a shortcode stored in CloudFiles by simply performing a head on the object. This is the method used by the Flask app when expanding a url by hitting[SomeShortCode]

Other handy things you could do? Use CloudFiles expiring object support to automatically expire url's, switch it to use FormPost to post to swift...and other stuff, and things, yea...