#!/usr/local/bin/python import anydbm,cgi,os; db=anydbm.open('/tmp/short_db','c') form = cgi.FieldStorage() if form.getfirst('url','') and len(db) >= 10000: print 'content-type: text/html\r\n\r\nDB Full' elif form.getfirst('url',''): id = unichr(len(db)+1+100).encode('utf-16be').encode('base64').strip().rstrip('='); db[id] = form.getfirst('url','')[:4096] print 'content-type: text/html\r\n\r\nhttp://tungwaiyip.info/shorturl/%s' % (id,id) elif os.environ.get('PATH_INFO','')[:50].lstrip('/'): print 'status: 302 found\r\nlocation: %s\r\n\r\n' % (db.get(os.environ.get('PATH_INFO','')[:50].lstrip('/'),'.')) else: print 'content-type: text/html\r\n\r\nThe World\'s Shortest Short URL Generator

The World\'s Shortest Short URL Generator

Please enter full URL:

URL

About  Source Code

Disclaimer: This site is built for fun only. Short URLs generated are only going to be valid for a short period of time.

' db.close()