I have a blueprint object "api"
api.py
from flask import Blueprint api = Blueprint('api', __name__) @api.route('/') def call_api(): return "" init.py:
from flask import Flask, Blueprint from api import api public = Blueprint('public', __name__) @public.route('/') def home(): return render_template('public/home.html') app = Flask(__name__) app.register_blueprint(public) app.register_blueprint(api, subdomain='api') print(list(app.url_map.iter_rules())) And when I type:
print(list(app.url_map.iter_rules())) I get the following result:
[<Rule 'api|/' (GET, HEAD, OPTIONS) -> api.call_api>, <Rule '/' (GET, HEAD, OPTIONS) -> public.home>, <Rule '/static/<filename>' (GET, HEAD, OPTIONS) - But I need to write the result in a text document, as the result is higher.
How do I write app.url_map.iter_rules () to a text document?