Fix issue where redirecting to endpoints page would only show table
This commit is contained in:
36
app.py
36
app.py
@@ -535,18 +535,6 @@ def plot_query(query_id):
|
||||
return plot_div
|
||||
|
||||
def get_routes():
|
||||
|
||||
return routes
|
||||
|
||||
@app.route('/endpoints')
|
||||
def list_endpoints():
|
||||
"""
|
||||
Lists all API endpoints available in the Flask application.
|
||||
|
||||
This endpoint retrieves all registered routes, excluding static routes,
|
||||
and displays their details such as endpoint name, URL, allowed HTTP methods,
|
||||
view function name, and a brief description.
|
||||
"""
|
||||
routes = []
|
||||
for rule in app.url_map.iter_rules():
|
||||
if rule.endpoint == 'static':
|
||||
@@ -560,7 +548,26 @@ def list_endpoints():
|
||||
'doc': app.view_functions[rule.endpoint].__doc__
|
||||
}
|
||||
routes.append(route_info)
|
||||
return routes
|
||||
|
||||
@app.route('/endpoints')
|
||||
def list_endpoints():
|
||||
"""
|
||||
Lists all API endpoints available in the Flask application.
|
||||
|
||||
This endpoint retrieves all registered routes, excluding static routes,
|
||||
and displays their details such as endpoint name, URL, allowed HTTP methods,
|
||||
view function name, and a brief description.
|
||||
"""
|
||||
routes = get_routes()
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'endpoints.html', 'content', routes=routes)
|
||||
return render_template('endpoints.html', routes=routes)
|
||||
|
||||
@app.route('/endpoints/search')
|
||||
def search_endpoints():
|
||||
routes = get_routes()
|
||||
search = request.args.get('search', '').lower()
|
||||
if search:
|
||||
routes = [
|
||||
@@ -572,10 +579,7 @@ def list_endpoints():
|
||||
or (route['doc'] and search in route['doc'].lower())
|
||||
]
|
||||
|
||||
if htmx:
|
||||
return render_template('partials/endpoints_table.html', routes=routes)
|
||||
|
||||
return render_template('endpoints.html', routes=routes)
|
||||
return render_template('partials/endpoints_table.html', routes=routes)
|
||||
|
||||
@app.teardown_appcontext
|
||||
def closeConnection(exception):
|
||||
|
||||
Reference in New Issue
Block a user