diff --git a/Html/apps/extensions.py b/Html/apps/extensions.py index 9a59c93..2fa30ef 100644 --- a/Html/apps/extensions.py +++ b/Html/apps/extensions.py @@ -14,7 +14,7 @@ from typing import Optional mongo = PyMongo() -socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet",always_connect=True) # 不直接传 app +socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet",always_connect=False) # 不直接传 app cors = CORS() # ===== 你的全局对象 ===== # Backboard @@ -38,7 +38,7 @@ def init_extensions(app): cors_allowed_origins='*',#app.config["VSCODE_WEB_URL"], ping_timeout=app.config["SOCKETIO_PING_TIMEOUT"], ping_interval=app.config["SOCKETIO_PING_INTERVAL"], - max_payload_size=50000000, async_mode="eventlet",always_connect=True + max_payload_size=50000000, async_mode="eventlet",always_connect=False ) cors.init_app( app, diff --git a/Html/apps/sockets/namespaces.py b/Html/apps/sockets/namespaces.py index 84bc7d2..45e7e7d 100644 --- a/Html/apps/sockets/namespaces.py +++ b/Html/apps/sockets/namespaces.py @@ -175,7 +175,7 @@ class AgentNamespace(Namespace): route='dialog', callback=receive_ase_dialog, entry=self, - init_data={'room': user_uuid} + init_data={'room':user_uuid} ) user_uuid2ase_client[user_uuid].register_route_with_entry( route='dialog-hint', @@ -193,13 +193,13 @@ class AgentNamespace(Namespace): route='judge', callback=receive_ase_judge, entry=self, - init_data={'room': user_uuid} + init_data={'room':user_uuid} ) user_uuid2ase_client[user_uuid].register_route_with_entry( route='next_chapter', callback=receive_ase_next_chapter, entry=self, - init_data={'room': user_uuid} + init_data={'room':user_uuid} ) user_uuid2ase_client[user_uuid].register_route_with_entry( route='chapter_score', diff --git a/Html/apps/views/vscode.py b/Html/apps/views/vscode.py index 71226f3..d0b2d19 100644 --- a/Html/apps/views/vscode.py +++ b/Html/apps/views/vscode.py @@ -91,38 +91,6 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name): - caddy_conf = f""" - handle_path /vsc{user_id}/* {{ - reverse_proxy localhost:{code_server_port} - }} - """ - caddy_config_path = "/etc/caddy/Caddyfile" - with open(caddy_config_path, "r") as f: - lines = f.readlines() - pattern = re.compile( - r'handle_path\s+/vsc' + re.escape(user_id) + r'/\* {.*?reverse_proxy.*?}', - re.DOTALL - ) - for i in range(len(lines)): - if (lines[i].strip()==''): lines[i]='' - content = "".join(lines) - if pattern.search(content): - new_content = pattern.sub('', content) - lines = new_content.splitlines(keepends=True) - if len(lines) >= 2: - insert_position = len(lines) - 2 - else: - insert_position = len(lines) - if caddy_conf[-1] not in ['\n', '\r']: - caddy_conf += '\n' - lines.insert(insert_position, caddy_conf) - with open(caddy_config_path, "w") as f: - f.writelines(lines) - - try: - subprocess.run(["sudo", "caddy", "reload", "--config", "/etc/caddy/Caddyfile"]) - except subprocess.CalledProcessError as e: - print(f"Error reload caddy {e}") cfg = current_app.config["VSCODE_WEB_PATH"] path_for_vscode = path_dir diff --git a/code-server-like/app/extensions.py b/code-server-like/app/extensions.py index 83289a6..27bde5e 100644 --- a/code-server-like/app/extensions.py +++ b/code-server-like/app/extensions.py @@ -3,12 +3,12 @@ from flask_socketio import SocketIO from .config import Config # 初始化扩展 cors = CORS() -socketio = SocketIO(path='vsc-like-ws',cors_allowed_origins="*",max_payload_size=5242880, async_mode="eventlet",always_connect=True) # 不直接传 app +socketio = SocketIO(path='vsc-like-ws',cors_allowed_origins="*",max_payload_size=5242880, async_mode="eventlet",always_connect=False) # 不直接传 app session_paths = {} def init_extensions(app): cors.init_app(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True) - socketio.init_app(app, cors_allowed_origins="*", max_payload_size=5242880, async_mode="eventlet",always_connect=True) + socketio.init_app(app, cors_allowed_origins="*", max_payload_size=5242880, async_mode="eventlet",always_connect=False) app.extensions["session_paths"] = session_paths def register_namespaces(app):