diff --git a/app.py b/app.py index 9e768d6..863685b 100644 --- a/app.py +++ b/app.py @@ -298,6 +298,26 @@ def stream_names() -> Union[Response, str]: return jsonify(get_stream_names(base_url, session["auth_credentials"])) +@app.route('/config', methods=['GET', 'POST']) +def config(): + """Handles access to the configuration page.""" + if request.method == 'POST': + password = request.form.get('password') + if password == app.config['CONFIG_PASSWORD']: + session['config_logged_in'] = True + return redirect(url_for('config_dashboard')) + else: + return render_template('config.html', error='Invalid password') + return render_template('config.html') + +@app.route('/config/dashboard') +def config_dashboard(): + """Renders the configuration dashboard.""" + if not session.get('config_logged_in'): + return redirect(url_for('config')) + return render_template('config_dashboard.html') + + if __name__ == "__main__": app.run( debug=app.config["DEBUG"], diff --git a/templates/base.html b/templates/base.html index ee7ef96..54a4278 100644 --- a/templates/base.html +++ b/templates/base.html @@ -46,7 +46,7 @@ @@ -82,32 +82,6 @@ }, function(err) { console.log('ServiceWorker registration failed: ', err); }); - - document.getElementById('version-link').addEventListener('click', function(event) { - event.preventDefault(); - fetch('{{ url_for("send_test_notification") }}', { - method: 'POST' - }).then(response => { - console.log('Response status:', response.status); - console.log('Response headers:', response.headers); - return response.text().then(text => { - console.log('Response body:', text); - try { - return JSON.parse(text); - } catch (e) { - console.error('Failed to parse JSON:', e); - throw new Error('Server returned non-JSON response'); - } - }); - }).then(data => { - console.log('Parsed data:', data); - if (data.message) { - console.log(data.message); - } - }).catch(err => { - console.error('Error sending test notification:', err); - }); - }); } function askPermission(registration) { diff --git a/templates/config.html b/templates/config.html new file mode 100644 index 0000000..d98eb41 --- /dev/null +++ b/templates/config.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} + +{% block title %}Config Access{% endblock %} + +{% block content %} +
+
+
+
+

Enter Password

+
+
+ {% if error %} +
{{ error }}
+ {% endif %} +
+
+ + +
+ +
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/config_dashboard.html b/templates/config_dashboard.html new file mode 100644 index 0000000..96b471a --- /dev/null +++ b/templates/config_dashboard.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block title %}Config Dashboard{% endblock %} + +{% block content %} +
+

Configuration Dashboard

+

Welcome to the configuration page.

+ +
+{% endblock %} + +{% block scripts %} +{{ super() }} + +{% endblock %} \ No newline at end of file