diff --git a/app.py b/app.py
index 2d8a78e..c2c9a6c 100644
--- a/app.py
+++ b/app.py
@@ -387,6 +387,24 @@ def proxy_extra_urls():
return jsonify({"error": str(e)}), 502
+@app.route('/extra_urls_file', methods=['GET'])
+def proxy_extra_urls_file():
+ """Proxies the request to get the extra_urls.txt file from the backend."""
+ if not session.get("config_logged_in"):
+ return jsonify({'error': 'Unauthorized'}), 401
+
+ backend_url = f"{app.config['BACKEND_URL']}/extra_urls_file"
+ credentials = base64.b64decode(session["auth_credentials"]).decode()
+ username, password = credentials.split(":", 1)
+ auth = requests.auth.HTTPBasicAuth(username, password)
+
+ try:
+ response = requests.get(backend_url, auth=auth)
+ 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__":
app.run(
debug=app.config["DEBUG"],
diff --git a/templates/config_dashboard.html b/templates/config_dashboard.html
index 5edaca3..5e91354 100644
--- a/templates/config_dashboard.html
+++ b/templates/config_dashboard.html
@@ -60,6 +60,7 @@
+
@@ -174,9 +175,20 @@
function fetchExtraUrlsList() {
fetch("{{ url_for('proxy_extra_urls') }}")
- .then(response => response.json())
+ .then(response => {
+ if (!response.ok) {
+ // Log the error response text for debugging
+ response.text().then(text => console.error('Error response from proxy:', text));
+ throw new Error(`HTTP error! Status: ${response.status}`);
+ }
+ return response.json();
+ })
.then(data => {
extraUrlsTableBody.innerHTML = '';
+ if (!Array.isArray(data)) {
+ console.error("Received data is not an array:", data);
+ throw new Error("Invalid data format received from server.");
+ }
if (data.length === 0) {
const row = extraUrlsTableBody.insertRow();
const cell = row.insertCell();
@@ -196,6 +208,15 @@
actionCell.appendChild(removeBtn);
});
}
+ })
+ .catch(e => {
+ console.error('Error during fetchExtraUrlsList:', e);
+ extraUrlsTableBody.innerHTML = '';
+ const row = extraUrlsTableBody.insertRow();
+ const cell = row.insertCell();
+ cell.colSpan = 2;
+ cell.textContent = 'Error loading extra URLs. See browser console for details.';
+ cell.classList.add('text-center', 'text-danger');
});
}
@@ -230,6 +251,11 @@
addExtraUrlBtn.addEventListener('click', addExtraUrl);
fetchExtraUrlsList();
+ const viewExtraUrlsFileBtn = document.getElementById('view-extra-urls-file-btn');
+ viewExtraUrlsFileBtn.addEventListener('click', () => {
+ window.open("{{ url_for('proxy_extra_urls_file') }}", '_blank');
+ });
+
// Other buttons
document.getElementById('send-test-notification-btn').addEventListener('click', function() {
fetch('{{ url_for("send_test_notification") }}', {