File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 2626from dotenv import load_dotenv
2727from flask import Flask
2828from flask import jsonify
29+ from flask import redirect
30+ from flask import url_for
2931from flask_cors import CORS
3032from flask_jwt_extended import JWTManager
3133from flask_mail import Mail
@@ -275,3 +277,35 @@ def no_jwt_callback(error_message):
275277# import tasks here to be registered by celery
276278
277279import PyMatcha .utils .tasks # noqa
280+
281+
282+ @application .route ("/" )
283+ def home ():
284+ return redirect (url_for ("site_map" ))
285+
286+
287+ @application .route ("/site-map" )
288+ def site_map ():
289+ links = []
290+ for rule in application .url_map .iter_rules ():
291+ # Filter out rules we can't navigate to in a browser
292+ # and rules that require parameters
293+ url = url_for (
294+ rule .endpoint ,
295+ ** (rule .defaults or {}),
296+ uid = - 1 ,
297+ message_id = - 1 ,
298+ with_uid = - 1 ,
299+ image_id = - 1 ,
300+ amount = - 1 ,
301+ token = - 1 ,
302+ filename = - 1 ,
303+ )
304+ methods = ""
305+ for m in rule .methods :
306+ if m == "HEAD" or m == "OPTIONS" :
307+ continue
308+ methods += f"{ m } "
309+ links .append (f"{ methods } { url } " .split ("?" )[0 ])
310+ # links is now a list of url, endpoint tuples
311+ return jsonify (links ), 200
You can’t perform that action at this time.
0 commit comments