Finally fixtures.html working

parent beeec67c
Collecting flask-cors
Using cached flask_cors-6.0.1-py3-none-any.whl.metadata (5.3 kB)
Requirement already satisfied: flask>=0.9 in ./venv/lib/python3.13/site-packages (from flask-cors) (3.1.2)
Requirement already satisfied: Werkzeug>=0.7 in ./venv/lib/python3.13/site-packages (from flask-cors) (3.1.3)
Requirement already satisfied: blinker>=1.9.0 in ./venv/lib/python3.13/site-packages (from flask>=0.9->flask-cors) (1.9.0)
Requirement already satisfied: click>=8.1.3 in ./venv/lib/python3.13/site-packages (from flask>=0.9->flask-cors) (8.3.1)
Requirement already satisfied: itsdangerous>=2.2.0 in ./venv/lib/python3.13/site-packages (from flask>=0.9->flask-cors) (2.2.0)
Requirement already satisfied: jinja2>=3.1.2 in ./venv/lib/python3.13/site-packages (from flask>=0.9->flask-cors) (3.1.6)
Requirement already satisfied: markupsafe>=2.1.1 in ./venv/lib/python3.13/site-packages (from flask>=0.9->flask-cors) (3.0.3)
Using cached flask_cors-6.0.1-py3-none-any.whl (13 kB)
Installing collected packages: flask-cors
Successfully installed flask-cors-6.0.1
../assets/
\ No newline at end of file
......@@ -135,6 +135,10 @@ class MbetterClientApplication:
# Preserve command line Qt overlay setting
stored_settings.qt.use_native_overlay = self.settings.qt.use_native_overlay
# Preserve command line debug settings
stored_settings.debug_overlay = self.settings.debug_overlay
stored_settings.debug_player = self.settings.debug_player
# Preserve command line SSL settings
stored_settings.web.enable_ssl = self.settings.web.enable_ssl
stored_settings.web.ssl_cert_path = self.settings.web.ssl_cert_path
......
......@@ -234,8 +234,6 @@ class MessageBus:
if component_name != message.sender: # Don't send to sender
if self._deliver_to_queue(queue, message):
success_count += 1
logger.debug(f"Broadcast message delivered to {success_count} components")
else:
# Send to specific recipient
if message.recipient in self._queues:
......
This diff is collapsed.
......@@ -10,6 +10,7 @@ from flask import Flask, request, jsonify, render_template, redirect, url_for, s
from flask_login import LoginManager, login_required, current_user
from flask_jwt_extended import JWTManager, create_access_token, jwt_required as flask_jwt_required
from flask_socketio import SocketIO, emit
from flask_cors import CORS
from werkzeug.serving import make_server
import threading
......@@ -19,6 +20,7 @@ from ..config.settings import WebConfig
from ..config.manager import ConfigManager
from ..database.manager import DatabaseManager
from ..utils.ssl_utils import get_ssl_certificate_paths, create_ssl_context
from flask_cors import CORS
from .auth import AuthManager
from .api import DashboardAPI
from .routes import main_bp, auth_bp, api_bp
......@@ -106,6 +108,17 @@ class WebDashboard(ThreadedComponent):
template_folder=str(template_dir),
static_folder=str(static_dir))
# Initialize CORS
CORS(app, resources={
r"/api/*": {
"origins": ["*"],
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization", "X-Requested-With"],
"expose_headers": ["Content-Range", "X-Content-Range"],
"supports_credentials": False
}
})
# Initialize SocketIO (disabled for PyInstaller compatibility)
try:
socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading')
......@@ -133,6 +146,16 @@ class WebDashboard(ThreadedComponent):
jwt_manager = JWTManager(app)
# Initialize CORS
CORS(app, resources={
r"/api/*": {
"origins": ["file://", "http://127.0.0.1:*", "http://localhost:*"],
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization"],
"supports_credentials": False
}
})
# User loader for Flask-Login
@login_manager.user_loader
def load_user(user_id):
......@@ -469,8 +492,6 @@ class WebDashboard(ThreadedComponent):
def _process_message(self, message: Message):
"""Process received message"""
try:
logger.debug(f"WebDashboard processing message: {message}")
# Handle messages directly since some messages don't trigger subscription handlers
if message.type == MessageType.CONFIG_UPDATE:
self._handle_config_update(message)
......
......@@ -11,13 +11,57 @@ class OverlayManager {
try {
// Wait for DOM to be fully loaded
this.waitForFullInitialization(() => {
// Check if Qt WebChannel is available
// Check if Qt WebChannel transport is available (set by QWebEnginePage.setWebChannel)
if (typeof qt !== 'undefined' && qt.webChannelTransport) {
// Use the transport provided by Qt WebEngine
new QWebChannel(qt.webChannelTransport, (channel) => {
// Connect to overlay object
window.overlay = channel.objects.overlay;
// Flush any buffered console messages
if (window.flushConsoleBuffer) {
window.flushConsoleBuffer();
}
// Connect signals if overlay object exists
if (window.overlay) {
// Connect positionChanged signal
if (window.overlay.positionChanged) {
window.overlay.positionChanged.connect((position, duration) => {
if (position !== null && duration !== null) {
this.updateProgress(position, duration);
} else {
console.warn('positionChanged signal received null/undefined parameters, skipping');
}
});
}
// Connect videoInfoChanged signal
if (window.overlay.videoInfoChanged) {
window.overlay.videoInfoChanged.connect((info) => {
if (info && typeof info === 'object') {
this.updateVideoInfo(info);
} else {
console.warn('videoInfoChanged signal received null/undefined parameter, skipping');
}
});
}
// Process pending updates after full initialization
setTimeout(() => this.processPendingUpdates(), 100);
console.log('WebChannel connected and ready');
} else {
console.warn('Overlay object not found in WebChannel');
}
});
} else {
console.warn('Qt WebChannel transport not available, falling back to QtWebChannel constructor');
// Fallback: try the old method
if (typeof Qt === 'object' && typeof QtWebChannel === 'function') {
// Create channel and connect signals
const channel = new QtWebChannel();
// Connect to overlay object
channel.connectTo('overlay', (overlay) => {
window.overlay = overlay;
// Connect positionChanged signal
overlay.positionChanged.connect((position, duration) => {
if (position !== null && duration !== null) {
......@@ -38,14 +82,14 @@ class OverlayManager {
// Process pending updates after full initialization
setTimeout(() => this.processPendingUpdates(), 100);
console.log('WebChannel connected via fallback method');
});
console.log('WebChannel connected and ready');
} else {
console.warn('QtWebChannel not available');
console.warn('QtWebChannel not available either');
// Retry with exponential backoff
setTimeout(() => this.initWebChannel(), 1000);
}
}
});
} catch (error) {
console.error('WebChannel initialization error:', error);
......
......@@ -21,6 +21,7 @@ Werkzeug>=2.3.0
Jinja2>=3.1.0
WTForms>=3.0.0
Flask-SocketIO>=5.3.0
Flask-CORS>=4.0.0
# Configuration and environment
python-dotenv>=0.19.0
......
#!/usr/bin/env python3
"""
Test script to check API endpoints for debugging fixtures overlay
"""
import requests
import json
import sys
from pathlib import Path
def test_fixtures_api():
"""Test the fixtures API endpoint"""
print("Testing fixtures API endpoint...")
# Try different possible URLs
urls_to_test = [
"http://127.0.0.1:5001/api/fixtures",
"http://localhost:5001/api/fixtures",
"http://127.0.0.1:5000/api/fixtures",
"http://localhost:5000/api/fixtures"
]
for url in urls_to_test:
print(f"\nTrying URL: {url}")
try:
response = requests.get(url, timeout=5)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
try:
data = response.json()
print("Response data:")
print(json.dumps(data, indent=2))
if 'success' in data and data['success']:
print(f"✅ SUCCESS: Found {data.get('total', 0)} fixtures")
return True
else:
print("❌ API returned success=false")
return False
except json.JSONDecodeError as e:
print(f"❌ Invalid JSON response: {e}")
print(f"Raw response: {response.text[:500]}...")
return False
else:
print(f"❌ HTTP Error: {response.status_code}")
print(f"Response: {response.text[:200]}...")
except requests.exceptions.ConnectionError:
print("❌ Connection refused - server not running")
except requests.exceptions.Timeout:
print("❌ Request timed out")
except Exception as e:
print(f"❌ Error: {e}")
print("\n❌ All URLs failed - API server may not be running")
return False
def test_web_dashboard_status():
"""Test if web dashboard is running"""
print("\nTesting web dashboard status...")
urls_to_test = [
"http://127.0.0.1:5001/",
"http://localhost:5001/",
"http://127.0.0.1:5000/",
"http://localhost:5000/"
]
for url in urls_to_test:
print(f"Trying URL: {url}")
try:
response = requests.get(url, timeout=5)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
print("✅ Web dashboard is running")
return True
except Exception as e:
print(f"❌ Error: {e}")
print("❌ Web dashboard not accessible")
return False
def main():
print("=== MbetterClient API Test ===")
# Test web dashboard first
web_running = test_web_dashboard_status()
if not web_running:
print("\n⚠️ Web dashboard is not running. Make sure to start the web server first.")
print("Run: python main.py --web-only")
sys.exit(1)
# Test fixtures API
api_working = test_fixtures_api()
if api_working:
print("\n✅ API test completed successfully")
else:
print("\n❌ API test failed")
print("\nTroubleshooting tips:")
print("1. Make sure the web server is running")
print("2. Check if the database has fixture data")
print("3. Check the web server logs for errors")
print("4. Verify the fixtures endpoint is properly configured")
if __name__ == "__main__":
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment