move routes endpoint to debug blueprint
This commit is contained in:
parent
e5f16f7292
commit
e660627249
2 changed files with 33 additions and 0 deletions
|
@ -111,6 +111,7 @@ def add_routes(application):
|
||||||
from views.order import order_bp
|
from views.order import order_bp
|
||||||
from views.general import general_bp
|
from views.general import general_bp
|
||||||
from views.stats import stats_blueprint
|
from views.stats import stats_blueprint
|
||||||
|
from views.debug import debug_bp
|
||||||
from login import auth_bp
|
from login import auth_bp
|
||||||
from zeus import oauth_bp
|
from zeus import oauth_bp
|
||||||
|
|
||||||
|
@ -120,6 +121,9 @@ def add_routes(application):
|
||||||
application.register_blueprint(auth_bp, url_prefix='/')
|
application.register_blueprint(auth_bp, url_prefix='/')
|
||||||
application.register_blueprint(oauth_bp, url_prefix='/')
|
application.register_blueprint(oauth_bp, url_prefix='/')
|
||||||
|
|
||||||
|
if application.debug:
|
||||||
|
application.register_blueprint(debug_bp, url_prefix='/debug')
|
||||||
|
|
||||||
|
|
||||||
def add_template_filters(app):
|
def add_template_filters(app):
|
||||||
@app.template_filter('countdown')
|
@app.template_filter('countdown')
|
||||||
|
|
29
app/views/debug.py
Normal file
29
app/views/debug.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from flask import Blueprint
|
||||||
|
from flask import current_app as app
|
||||||
|
from flask import url_for
|
||||||
|
from flask_login import login_required
|
||||||
|
|
||||||
|
debug_bp = Blueprint('debug_bp', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@debug_bp.route('/routes')
|
||||||
|
@login_required
|
||||||
|
def list_routes():
|
||||||
|
import urllib
|
||||||
|
output = []
|
||||||
|
for rule in app.url_map.iter_rules():
|
||||||
|
options = {}
|
||||||
|
for arg in rule.arguments:
|
||||||
|
options[arg] = "[{0}]".format(arg)
|
||||||
|
print(rule.endpoint)
|
||||||
|
methods = ','.join(rule.methods)
|
||||||
|
url = url_for(rule.endpoint, **options)
|
||||||
|
line = urllib.parse.unquote("{:50s} {:20s} {}".format(
|
||||||
|
rule.endpoint, methods, url))
|
||||||
|
output.append(line)
|
||||||
|
|
||||||
|
string = ''
|
||||||
|
for line in sorted(output):
|
||||||
|
string += line + "<br/>"
|
||||||
|
|
||||||
|
return string
|
Loading…
Reference in a new issue