diff --git a/app.py b/app.py index 5c6e80a..540d85c 100644 --- a/app.py +++ b/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): diff --git a/templates/endpoints.html b/templates/endpoints.html index 0be769c..af656bd 100644 --- a/templates/endpoints.html +++ b/templates/endpoints.html @@ -11,7 +11,7 @@