Created
February 5, 2019 02:29
-
-
Save jasonrhaas/41ac789259c251133b98dab16558543a to your computer and use it in GitHub Desktop.
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('/<tiny_url>', methods=['GET']) | |
def get_long_url(tiny_url): | |
if request.method == 'GET': | |
try: | |
url_id = short_url.decode_url(tiny_url) | |
except Exception: | |
abort(500) | |
app.logger.debug(url_id) | |
url = Url.query.filter_by(id=url_id).first() | |
app.logger.debug(url) | |
if not url: | |
abort(404) | |
url.hits += 1 | |
db.session.add(url) | |
db.session.commit() | |
return redirect(url.long) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment