Skip to content

Instantly share code, notes, and snippets.

@xiazhibin
Last active May 17, 2017 07:26
Show Gist options
  • Save xiazhibin/29d9bcd756873de4bf2fd8899f365f22 to your computer and use it in GitHub Desktop.
Save xiazhibin/29d9bcd756873de4bf2fd8899f365f22 to your computer and use it in GitHub Desktop.
flask_script list all rule in
@manager.command
def list_routes():
import urllib
output = []
for rule in app.url_map.iter_rules():
if rule.endpoint == 'static':
continue
methods = ','.join(rule.methods)
line = urllib.unquote("{:30s} {:30s} {}".format(rule.rule, rule.endpoint, methods))
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