manual check on config page

This commit is contained in:
Karl 2025-07-19 09:05:28 +01:00
parent d519a268a0
commit c62441a2d1
2 changed files with 29 additions and 0 deletions

13
app.py
View File

@ -317,6 +317,19 @@ def config_dashboard():
return redirect(url_for('config')) return redirect(url_for('config'))
return render_template('config_dashboard.html') return render_template('config_dashboard.html')
@app.route('/check-expiring-accounts', methods=['POST'])
def check_expiring_accounts():
"""Proxies the request to check for expiring accounts to the backend."""
if not session.get("config_logged_in"):
return jsonify({'error': 'Unauthorized'}), 401
backend_url = f"{app.config['BASE_URL']}/check-expiry"
try:
response = requests.post(backend_url)
return Response(response.content, status=response.status_code, mimetype=response.headers['Content-Type'])
except requests.exceptions.RequestException as e:
return jsonify({"error": str(e)}), 502
if __name__ == "__main__": if __name__ == "__main__":
app.run( app.run(

View File

@ -7,6 +7,7 @@
<h2>Configuration Dashboard</h2> <h2>Configuration Dashboard</h2>
<p>Welcome to the configuration page.</p> <p>Welcome to the configuration page.</p>
<button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button> <button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button>
<button id="check-expiring-accounts-btn" class="btn btn-info">Check Expiring Accounts</button>
</div> </div>
{% endblock %} {% endblock %}
@ -27,5 +28,20 @@ document.getElementById('send-test-notification-btn').addEventListener('click',
alert('An error occurred while sending the test notification.'); alert('An error occurred while sending the test notification.');
}); });
}); });
document.getElementById('check-expiring-accounts-btn').addEventListener('click', function() {
fetch('{{ url_for("check_expiring_accounts") }}', {
method: 'POST'
}).then(response => {
if (response.ok) {
alert('Expiring accounts check triggered successfully!');
} else {
alert('Failed to trigger expiring accounts check.');
}
}).catch(err => {
console.error('Error triggering expiring accounts check:', err);
alert('An error occurred while triggering the expiring accounts check.');
});
});
</script> </script>
{% endblock %} {% endblock %}