looking for extra urls
This commit is contained in:
parent
3888e6d536
commit
1dd83f4230
18
app.py
18
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"],
|
||||
|
@ -60,6 +60,7 @@
|
||||
<input type="text" class="form-control" id="extra-url-input" placeholder="Enter Extra URL">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" id="add-extra-url-btn">Add</button>
|
||||
<button class="btn btn-secondary" id="view-extra-urls-file-btn">View extra_urls.txt</button>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
@ -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") }}', {
|
||||
|
Loading…
x
Reference in New Issue
Block a user