fix: changes the API for localhost
parent
0c2d220918
commit
1054d3dc0b
Binary file not shown.
Binary file not shown.
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE = 'http://localhost:5000/api';
|
||||
const API_BASE = 'http://192.168.1.8:5000/api';
|
||||
|
||||
const grid = document.getElementById('stations-grid');
|
||||
const addStationCardTmpl = document.getElementById('add-station-card-template');
|
||||
|
|
|
|||
Loading…
Reference in New Issue