Skip to content

Instantly share code, notes, and snippets.

@jaydeepkarale
Created June 23, 2022 13:03
Show Gist options
  • Save jaydeepkarale/46cf2bc60d73f48d30e0db1d1111f5d9 to your computer and use it in GitHub Desktop.
Save jaydeepkarale/46cf2bc60d73f48d30e0db1d1111f5d9 to your computer and use it in GitHub Desktop.
redirect logic for url shortner
@routes.get("/{code}")
async def redirect_to_longurl(request):
"""Function to retrieve long URL based on code
:param request: HTTP request
"""
data = request.match_info["code"]
longurl = cursor.execute("SELECT longurl from URLSHORTNER where code = ?",(data,)).fetchone()
print(longurl[0])
return web.HTTPFound(longurl[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment