Skip to content

Instantly share code, notes, and snippets.

@caio-nas
Created June 4, 2014 13:35
Show Gist options
  • Save caio-nas/20444330b9c7243bd773 to your computer and use it in GitHub Desktop.
Save caio-nas/20444330b9c7243bd773 to your computer and use it in GitHub Desktop.
@manager.command
def list_routes():
import urllib
from flask import url_for
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):
logger.debug(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment