Created
August 14, 2021 10:02
-
-
Save ashutoshkrris/9c6bd129cfb9046388565f0856e5a014 to your computer and use it in GitHub Desktop.
Redirect to original URL
This file contains hidden or 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
@app.route('/<short_id>') | |
def redirect_url(short_id): | |
link = ShortUrls.query.filter_by(short_id=short_id).first() | |
if link: | |
return redirect(link.original_url) | |
else: | |
flash('Invalid URL') | |
return redirect(url_for('index')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment