def redir(encoded_url): try: id = base_conv(encoded_url, input_base=62, output_base=10) url = Url.retrieve(id) return redirect(url.long_url) except excepts.NotFoundException: return notfound_error() except: return undefined_error()