2019-09-04 17:18:11 +02:00
|
|
|
from flask import Blueprint
|
|
|
|
from flask import current_app as app
|
|
|
|
from flask import url_for
|
|
|
|
from flask_login import login_required
|
|
|
|
|
2019-09-05 03:33:29 +02:00
|
|
|
debug_bp = Blueprint("debug_bp", __name__)
|
2019-09-04 17:18:11 +02:00
|
|
|
|
|
|
|
|
2019-09-05 03:33:29 +02:00
|
|
|
@debug_bp.route("/routes")
|
2019-09-04 17:18:11 +02:00
|
|
|
@login_required
|
2019-09-08 01:34:16 +02:00
|
|
|
def list_routes() -> str:
|
2019-09-04 17:18:11 +02:00
|
|
|
import urllib
|
2019-09-05 03:33:29 +02:00
|
|
|
|
2019-09-04 17:18:11 +02:00
|
|
|
output = []
|
|
|
|
for rule in app.url_map.iter_rules():
|
|
|
|
options = {}
|
|
|
|
for arg in rule.arguments:
|
|
|
|
options[arg] = "[{0}]".format(arg)
|
|
|
|
print(rule.endpoint)
|
2019-09-05 03:33:29 +02:00
|
|
|
methods = ",".join(rule.methods)
|
2019-09-04 17:18:11 +02:00
|
|
|
url = url_for(rule.endpoint, **options)
|
2019-09-05 03:33:29 +02:00
|
|
|
line = urllib.parse.unquote(
|
|
|
|
"{:50s} {:20s} {}".format(rule.endpoint, methods, url)
|
|
|
|
)
|
2019-09-04 17:18:11 +02:00
|
|
|
output.append(line)
|
|
|
|
|
2019-09-05 03:33:29 +02:00
|
|
|
string = ""
|
2019-09-04 17:18:11 +02:00
|
|
|
for line in sorted(output):
|
|
|
|
string += line + "<br/>"
|
|
|
|
|
|
|
|
return string
|