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 http://small.blk.io/e08e9d.
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://small.blk.io/e08e9d 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-Object-Meta-Longurl: http://bloomberg.com X-Timestamp: 1381128074.94653 X-Trans-Id: txb4163f76b17c4753bc188-0052525e7fdfw1 <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="1; url=http://bloomberg.com"> <script> window.location.href = "http://bloomberg.com" </script> <title>http://bloomberg.com - Page Redirection</title> </head> <body> If you are not redirected automatically to <a href='http://bloomberg.com'>http://bloomberg.com</a> follow <a href='http://bloomberg.com'>this link</a> </body> </html>
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 http://blk.io/[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...