I have a flask app with the below tree:
root/
- modules/
__init__.py
- common/
__init__.py
- citrixlb/
__init__.py # blueprint code
citrixlb.py # module class
- aws/
__init__.py # blueprint code
aws.py # module class
So I would like to know, is there a way to dynamically list all routes for all blueprints?
I have this in my root/__init__.py
:
# import our modules
from modules.citrixlb import *
from modules.aws import *
app.register_blueprint(aws)
app.register_blueprint(citrix)
If I can dynamically list all routes for all blueprints, I can auto generate the links.
Example:
DropDown: AWS
/aws
/aws/ec2
/aws/subnets
def get_bp_urls(blueprint):
from flask import Flask
temp_app = Flask(__name__)
temp_app.register_blueprint(blueprint)
return [str(p) for p in temp_app.url_map.iter_rules()]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With