attempting proxying

This commit is contained in:
2025-12-09 16:04:52 -05:00
parent 18e8fdb0a3
commit 611913c0f6
2 changed files with 13 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ from flask import Response
from events.types.event import Event
logger = logging.getLogger(__name__)
# Maps user_id → dict of {connection_id: queue}
user_queues: Dict[str, Dict[str, queue.Queue]] = {}
logging.basicConfig(level=logging.INFO)
@@ -33,6 +35,8 @@ def send_to_user(user_id: str, data: Dict[str, Any]):
# Send to all connections for this user
for connection_id, q in user_queues[user_id].items():
try:
logger.info(f"Sending message to {connection_id}")
q.put(message)
q.put(message, block=False)
except queue.Full:
# Skip if queue is full (connection might be dead)

View File

@@ -1,3 +1,5 @@
import logging
from flask import Flask, request
from flask_cors import CORS
@@ -9,6 +11,13 @@ from events.broadcaster import Broadcaster
from events.sse import sse_response_for_user, send_to_user
from db.default import initializeImages
# Configure logging once at application startup
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
app = Flask(__name__)
#CORS(app, resources={r"/api/*": {"origins": ["http://localhost:3000", "http://localhost:5173"]}})
app.register_blueprint(child_api)