added webhooks, moved app name and verison to simple config file
This commit is contained in:
83
app/web/routes/webhooks.py
Normal file
83
app/web/routes/webhooks.py
Normal file
@@ -0,0 +1,83 @@
|
||||
"""
|
||||
Webhook web routes for SneakyScanner.
|
||||
|
||||
Provides UI pages for managing webhooks and viewing delivery logs.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, flash, current_app
|
||||
|
||||
from web.auth.decorators import login_required
|
||||
from web.models import Webhook
|
||||
from web.services.webhook_service import WebhookService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
bp = Blueprint('webhooks', __name__)
|
||||
|
||||
|
||||
@bp.route('')
|
||||
@login_required
|
||||
def list_webhooks():
|
||||
"""
|
||||
Webhooks list page - shows all configured webhooks.
|
||||
|
||||
Returns:
|
||||
Rendered webhooks list template
|
||||
"""
|
||||
return render_template('webhooks/list.html')
|
||||
|
||||
|
||||
@bp.route('/new')
|
||||
@login_required
|
||||
def new_webhook():
|
||||
"""
|
||||
New webhook form page.
|
||||
|
||||
Returns:
|
||||
Rendered webhook form template
|
||||
"""
|
||||
return render_template('webhooks/form.html', webhook=None, mode='create')
|
||||
|
||||
|
||||
@bp.route('/<int:webhook_id>/edit')
|
||||
@login_required
|
||||
def edit_webhook(webhook_id):
|
||||
"""
|
||||
Edit webhook form page.
|
||||
|
||||
Args:
|
||||
webhook_id: Webhook ID to edit
|
||||
|
||||
Returns:
|
||||
Rendered webhook form template or 404
|
||||
"""
|
||||
webhook = current_app.db_session.query(Webhook).filter(Webhook.id == webhook_id).first()
|
||||
|
||||
if not webhook:
|
||||
flash('Webhook not found', 'error')
|
||||
return redirect(url_for('webhooks.list_webhooks'))
|
||||
|
||||
return render_template('webhooks/form.html', webhook=webhook, mode='edit')
|
||||
|
||||
|
||||
@bp.route('/<int:webhook_id>/logs')
|
||||
@login_required
|
||||
def webhook_logs(webhook_id):
|
||||
"""
|
||||
Webhook delivery logs page.
|
||||
|
||||
Args:
|
||||
webhook_id: Webhook ID
|
||||
|
||||
Returns:
|
||||
Rendered webhook logs template or 404
|
||||
"""
|
||||
webhook = current_app.db_session.query(Webhook).filter(Webhook.id == webhook_id).first()
|
||||
|
||||
if not webhook:
|
||||
flash('Webhook not found', 'error')
|
||||
return redirect(url_for('webhooks.list_webhooks'))
|
||||
|
||||
return render_template('webhooks/logs.html', webhook=webhook)
|
||||
Reference in New Issue
Block a user