from flask import Blueprint
from controllers.authController import authBlueprint
blueprint_list = [authBlueprint]
class RegisterBlueprint:
"""
A class for registering blueprints in a Flask application.
Args:
application (Flask): The Flask application instance to register the blueprints with.
Attributes:
blueprint (Blueprint): The main Blueprint object for this registration.
Example:
To use this class, create an instance and pass your Flask application instance:
register_blueprint = RegisterBlueprint(app)
"""
def __init__(self, application):
"""
Initializes a new RegisterBlueprint instance.
Args:
application (Flask): The Flask application instance to register the blueprints with.
"""
self.blueprint = Blueprint("routes", __name__, url_prefix="/api/v1")
self.register(application)
def register(self, application):
"""
Register the specified blueprints with the Flask application.
Args:
application (Flask): The Flask application instance to register the blueprints with.
"""
for bp in blueprint_list:
self.blueprint.register_blueprint(bp)
application.register_blueprint(self.blueprint)
if __name__ == "__main__":
# Assuming you create a Flask application instance
from flask import Flask
app = Flask(__name__)
# Example of how to use RegisterBlueprint:
register_blueprint = RegisterBlueprint(app)
# Run the Flask app
app.run(debug=True)