Commit 0cb1df41 authored by JackV's avatar JackV
Browse files

Avoid double-redirecting by using 2 separate routes

parent 331de5c5
......@@ -17,10 +17,13 @@ admin_dir = os.path.join(os.path.dirname(__file__), 'admin')
def handle_redirect(path):
final_url = redis_store.get('url.' + path)
if final_url:
redis_store.incr('count.' + path)
return flask.redirect(final_url)
if pure_string.match(path):
final_url = redis_store.get('url.' + path)
if final_url:
redis_store.incr('count.' + path)
return flask.redirect(final_url)
else:
return flask.abort(404)
else:
return flask.abort(404)
......@@ -99,12 +102,13 @@ def list_urls():
@app.route('/<path:path>')
def redirect_pure(path):
return handle_redirect(path)
@app.route('/<path:path>/')
def redirect(path):
if pure_string.match(path):
return handle_redirect(path)
else:
return flask.abort(404)
def redirect_slash(path):
return handle_redirect(path)
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment