From 1054d3dc0b637ab8a052cfdd60d7548d418fad41 Mon Sep 17 00:00:00 2001 From: Kirubakaran Date: Thu, 11 Sep 2025 01:55:34 +0530 Subject: [PATCH] fix: changes the API for localhost --- backend/__pycache__/models.cpython-313.pyc | Bin 3730 -> 3730 bytes .../__pycache__/mqtt_client.cpython-313.pyc | Bin 5309 -> 5309 bytes backend/main.py | 10 ++++++---- frontend/js/auth.js | 2 +- frontend/js/dashboard.js | 4 ++-- frontend/js/logs.js | 4 ++-- frontend/js/station_selection.js | 2 +- frontend/station_selection.html | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/backend/__pycache__/models.cpython-313.pyc b/backend/__pycache__/models.cpython-313.pyc index 84f70fd3874cc6f38ddbb865dfe93580cc0ad82e..1993280a1b70ee5fbd958232d80b157ef2ac0e0a 100644 GIT binary patch delta 20 acmbOvJ4u%NGcPX}0}yPm-@TE$oeuywiUoWC delta 20 acmbOvJ4u%NGcPX}0}yOzU%ipLoeuyx>IJj_ diff --git a/backend/core/__pycache__/mqtt_client.cpython-313.pyc b/backend/core/__pycache__/mqtt_client.cpython-313.pyc index 6305caf9e962e5e6f34228b3c1eeefe65afdde46..f4bbe5b951d6315c2f1b165245a794fe24f5189f 100644 GIT binary patch delta 20 acmdn1xmT0>GcPX}0}yPm-@TE0lL!Dn_y!vQ delta 20 acmdn1xmT0>GcPX}0}v#oZQsbfNdy2ttOf7@ diff --git a/backend/main.py b/backend/main.py index e5d87fa..3a38e8a 100644 --- a/backend/main.py +++ b/backend/main.py @@ -36,9 +36,11 @@ app = Flask(__name__) # CORS(app, resources={r"/api/*": {"origins": "http://127.0.0.1:5500"}}, supports_credentials=True) -CORS(app, resources={r"/api/*": {"origins": "http://127.0.0.1:5500"}}, supports_credentials=True, expose_headers='Content-Disposition') +# CORS(app, resources={r"/api/*": {"origins": "http://127.0.0.1:5500"}}, supports_credentials=True, expose_headers='Content-Disposition') -# CORS(app, resources={r"/api/*": {"origins": "http://localhost:5173"}}) +CORS(app, resources={r"/api/*": {"origins": ["http://192.168.1.8:5500","http://127.0.0.1:5500"]}}, supports_credentials=True, expose_headers='Content-Disposition') + +# CORS(app, resources={r"/api/*": {"origins": "http://localhost:5173"}}) , "http://127.0.0.1:5500" # This tells Flask: "For any route starting with /api/, allow requests # from the frontend running on http://localhost:5173". @@ -482,5 +484,5 @@ if __name__ == '__main__': mqtt_thread = threading.Thread(target=start_mqtt_clients, daemon=True) mqtt_thread.start() - print(f"Starting Flask-SocketIO server on http://localhost:5000") - socketio.run(app, host='0.0.0.0', port=5000) + print(f"Starting Flask-SocketIO server on http://192.168.1.8:5000") + socketio.run(app, host='192.168.1.8', port=5000) diff --git a/frontend/js/auth.js b/frontend/js/auth.js index e3f1071..9fbbc64 100644 --- a/frontend/js/auth.js +++ b/frontend/js/auth.js @@ -11,7 +11,7 @@ document.addEventListener('DOMContentLoaded', () => { const password = document.getElementById('password').value; try { - const response = await fetch('http://localhost:5000/api/login', { + const response = await fetch('http://192.168.1.8:5000/api/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }), diff --git a/frontend/js/dashboard.js b/frontend/js/dashboard.js index 2c184a5..0d744b2 100644 --- a/frontend/js/dashboard.js +++ b/frontend/js/dashboard.js @@ -1,7 +1,7 @@ document.addEventListener('DOMContentLoaded', () => { // --- CONFIGURATION --- - const SOCKET_URL = "http://localhost:5000"; - const API_BASE = "http://localhost:5000/api"; // Added for API calls + const SOCKET_URL = "http://192.168.1.8:5000"; + const API_BASE = "http://192.168.1.8:5000/api"; // Added for API calls // --- DOM ELEMENT REFERENCES --- const grid = document.getElementById('chambersGrid'); diff --git a/frontend/js/logs.js b/frontend/js/logs.js index ec64195..8d3512f 100644 --- a/frontend/js/logs.js +++ b/frontend/js/logs.js @@ -1,7 +1,7 @@ document.addEventListener('DOMContentLoaded', () => { // --- CONFIGURATION --- - const SOCKET_URL = "http://localhost:5000"; - const API_BASE = "http://localhost:5000/api"; + const SOCKET_URL = "http://192.168.1.8:5000"; + const API_BASE = "http://192.168.1.8:5000/api"; // --- DOM ELEMENT REFERENCES --- const stationNameEl = document.getElementById('station-name'); diff --git a/frontend/js/station_selection.js b/frontend/js/station_selection.js index cf8c7f8..fff3eb6 100644 --- a/frontend/js/station_selection.js +++ b/frontend/js/station_selection.js @@ -86,7 +86,7 @@ document.addEventListener('DOMContentLoaded', () => { // --- DATA FETCHING & STATUS POLLING --- const loadAndPollStations = async () => { try { - const response = await fetch('http://localhost:5000/api/stations'); + const response = await fetch('http://192.168.1.8:5000/api/stations'); if (!response.ok) throw new Error('Failed to fetch stations'); const stations = await response.json(); diff --git a/frontend/station_selection.html b/frontend/station_selection.html index cf3ced9..f44abf8 100644 --- a/frontend/station_selection.html +++ b/frontend/station_selection.html @@ -195,7 +195,7 @@