diff --git a/app.py b/app.py
index fc2990e..a7368ed 100644
--- a/app.py
+++ b/app.py
@@ -120,6 +120,25 @@ def proxy_save_subscription():
except requests.exceptions.RequestException as e:
return jsonify({"error": str(e)}), 502
+@app.route('/send-test-notification', methods=['POST'])
+def proxy_send_test_notification():
+ """Proxies the request to send a test notification to the backend."""
+ if not session.get("logged_in"):
+ return jsonify({'error': 'Unauthorized'}), 401
+
+ backend_url = f"{app.config['BASE_URL']}/send-test-notification"
+ credentials = base64.b64decode(session["auth_credentials"]).decode()
+ username, password = credentials.split(":", 1)
+
+ try:
+ response = requests.post(
+ backend_url,
+ auth=requests.auth.HTTPBasicAuth(username, password)
+ )
+ 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
+
@app.route("/home")
@cache.cached(timeout=60)
def home() -> str:
diff --git a/templates/base.html b/templates/base.html
index c44c732..fbbb887 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -46,7 +46,7 @@
@@ -65,6 +65,15 @@
}, function(err) {
console.log('ServiceWorker registration failed: ', err);
});
+
+ document.getElementById('version-link').addEventListener('click', function(event) {
+ event.preventDefault();
+ fetch('/send-test-notification', {
+ method: 'POST'
+ }).then(response => response.json())
+ .then(data => console.log(data.message))
+ .catch(err => console.error('Error sending test notification:', err));
+ });
}
function askPermission(registration) {