I'm trying to get all the routes for Flask when it's initially loaded but it seems to be super flaky. It'll give me all the routes half the time and the other half the time it'll give me this:
['/static/path:filename HEAD,GET,OPTIONS /static/path:filename']
I'm using this codeblock in the before_first_request and in the init constructor the Flask app. Any ideas how I can make this consistent? I want to do this as soon as the app is fully loaded automatically.
output = []
for rule in self.url_map.iter_rules():
try:
methods = ','.join(rule.methods)
line = urllib.parse.unquote("{:50s} {:20s} {}".format(str(rule), methods, rule))
output.append(line)
except Exception as e:
print("error with rule: " + str(rule))
dct = {"endpoints": output}