Last active
May 17, 2017 07:26
-
-
Save xiazhibin/29d9bcd756873de4bf2fd8899f365f22 to your computer and use it in GitHub Desktop.
flask_script list all rule in
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(): | |
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