Skip to content

Instantly share code, notes, and snippets.

@selfboot
Created June 15, 2016 12:34
Show Gist options
  • Select an option

  • Save selfboot/40e185f1d1aebdd40da5dae33d7f05d7 to your computer and use it in GitHub Desktop.

Select an option

Save selfboot/40e185f1d1aebdd40da5dae33d7f05d7 to your computer and use it in GitHub Desktop.
list the routes
@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