attempting proxying
This commit is contained in:
@@ -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)
|
||||
|
||||
9
main.py
9
main.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user