Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def has_no_empty_params(rule):
- defaults = rule.defaults if rule.defaults is not None else ()
- arguments = rule.arguments if rule.arguments is not None else ()
- return len(defaults) >= len(arguments)
- def list_endpoints():
- links = []
- for rule in app.url_map.iter_rules():
- # Filter out rules we can't navigate to in a browser
- # and rules that require parameters
- if has_no_empty_params(rule):
- url = flask.url_for(rule.endpoint)
- links.append((url, rule.endpoint))
- return flask.make_response(flask.jsonify({'links': links}), 200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement