In the Flask framework, I would like to be able to determine which request route would be selected to serve a URL, without having to actually request the URL itself. For example, if I have an app like:
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
pass
@app.route('/<id:int>')
@app.route('/<id:int>-<slug>')
def show_page(id, slug = None):
pass
then I'd like to be able to do something like (fictional example):
route = app.get_url_rule("/12345")
and get a result like:
('show_page', {'id':12345,'slug':None})
As far as I can tell, Flask doesn't expose any functionality like this on its own, but is there a way to possibly dig down into its request routing layer (or possibly Werkzeug) to implement this myself?