Created
June 15, 2016 12:34
-
-
Save selfboot/40e185f1d1aebdd40da5dae33d7f05d7 to your computer and use it in GitHub Desktop.
list the routes
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
| @manager.command | |
| def list_routes(): | |
| """List all the rules of route.""" | |
| import urllib | |
| output = [] | |
| for rule in app.url_map.iter_rules(): | |
| options = {} | |
| for arg in rule.arguments: | |
| options[arg] = "[{0}]".format(arg) | |
| methods = ','.join(rule.methods) | |
| url = url_for(rule.endpoint, **options) | |
| line = urllib.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, url)) | |
| output.append(line) | |
| for line in sorted(output): | |
| print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment