Created
June 23, 2022 13:03
-
-
Save jaydeepkarale/46cf2bc60d73f48d30e0db1d1111f5d9 to your computer and use it in GitHub Desktop.
redirect logic for url shortner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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