Flask: get current route
Simply use request.path
.
from flask import request...@app.route("/antitop/")@app.route("/top/")@requires_authdef show_top(): ... request.path ...
the most 'flasky' way to check which route triggered your view is, by request.url_rule
.
from flask import requestrule = request.url_ruleif 'antitop' in rule.rule: # request by '/antitop'elif 'top' in rule.rule: # request by '/top'