added webhooks, moved app name and verison to simple config file
This commit is contained in:
@@ -95,6 +95,9 @@ def create_app(config: dict = None) -> Flask:
|
||||
# Register error handlers
|
||||
register_error_handlers(app)
|
||||
|
||||
# Register context processors
|
||||
register_context_processors(app)
|
||||
|
||||
# Add request/response handlers
|
||||
register_request_handlers(app)
|
||||
|
||||
@@ -328,11 +331,13 @@ def register_blueprints(app: Flask) -> None:
|
||||
from web.api.scans import bp as scans_bp
|
||||
from web.api.schedules import bp as schedules_bp
|
||||
from web.api.alerts import bp as alerts_bp
|
||||
from web.api.webhooks import bp as webhooks_api_bp
|
||||
from web.api.settings import bp as settings_bp
|
||||
from web.api.stats import bp as stats_bp
|
||||
from web.api.configs import bp as configs_bp
|
||||
from web.auth.routes import bp as auth_bp
|
||||
from web.routes.main import bp as main_bp
|
||||
from web.routes.webhooks import bp as webhooks_bp
|
||||
|
||||
# Register authentication blueprint
|
||||
app.register_blueprint(auth_bp, url_prefix='/auth')
|
||||
@@ -340,10 +345,14 @@ def register_blueprints(app: Flask) -> None:
|
||||
# Register main web routes blueprint
|
||||
app.register_blueprint(main_bp, url_prefix='/')
|
||||
|
||||
# Register webhooks web routes blueprint
|
||||
app.register_blueprint(webhooks_bp, url_prefix='/webhooks')
|
||||
|
||||
# Register API blueprints
|
||||
app.register_blueprint(scans_bp, url_prefix='/api/scans')
|
||||
app.register_blueprint(schedules_bp, url_prefix='/api/schedules')
|
||||
app.register_blueprint(alerts_bp, url_prefix='/api/alerts')
|
||||
app.register_blueprint(webhooks_api_bp, url_prefix='/api/webhooks')
|
||||
app.register_blueprint(settings_bp, url_prefix='/api/settings')
|
||||
app.register_blueprint(stats_bp, url_prefix='/api/stats')
|
||||
app.register_blueprint(configs_bp, url_prefix='/api/configs')
|
||||
@@ -487,6 +496,35 @@ def register_error_handlers(app: Flask) -> None:
|
||||
return render_template('errors/500.html', error=error), 500
|
||||
|
||||
|
||||
def register_context_processors(app: Flask) -> None:
|
||||
"""
|
||||
Register template context processors.
|
||||
|
||||
Makes common variables available to all templates without having to
|
||||
pass them explicitly in every render_template call.
|
||||
|
||||
Args:
|
||||
app: Flask application instance
|
||||
"""
|
||||
@app.context_processor
|
||||
def inject_app_settings():
|
||||
"""
|
||||
Inject application metadata into all templates.
|
||||
|
||||
Returns:
|
||||
Dictionary of variables to add to template context
|
||||
"""
|
||||
from web.config import APP_NAME, APP_VERSION, REPO_URL
|
||||
|
||||
return {
|
||||
'app_name': APP_NAME,
|
||||
'app_version': APP_VERSION,
|
||||
'repo_url': REPO_URL
|
||||
}
|
||||
|
||||
app.logger.info("Context processors registered")
|
||||
|
||||
|
||||
def register_request_handlers(app: Flask) -> None:
|
||||
"""
|
||||
Register request and response handlers.
|
||||
|
||||
Reference in New Issue
Block a user